Got time?

D

dandelion

infobahn said:
I'd be interested to see your solution, then. :)

When I have time.

But some character sets (notably EBCDIC) do not have ASCII as a subset.

I don't assume the OP is using EBDIC. I may be wrong, but sofar, i've seen
no indication
this may be the case. You'd have to dig for some pretty outdated hard and
software
AFAIK.
So, to write the program(s) you suggest in full generality, you would
have to hard-code ASCII codes into the program, at the very least.

No. It suffices to hardcode '\n', '\r' '\t' and ' '. I'd be satified if the
OP
includes those and impressed if (s)he includes code for 'non-printable'
characters and interpunction characters. Besides, ASCII-tables are a
dime a dozen.
Also, on a note unrelated to ASCII, you failed to define "word".

On purpose.
Not a terrible omission, since it will cause the OP to think hard about
what is meant by the word "word" - an excellent exercise in itself. :)

That's the idea. I'm glad you agree.
 
I

infobahn

dandelion said:
I don't assume the OP is using EBDIC.

EBCDIC. Neither do I assume it. But I don't assume he's using ASCII
or a superset thereof, either.

I may be wrong, but sofar, i've seen
no indication
this may be the case. You'd have to dig for some pretty outdated hard and
software
AFAIK.

Well, not really. IBM mainframes, which are far from outdated, typically
use EBCDIC.

Er, yes, actually.
> It suffices to hardcode '\n', '\r' '\t' and ' '.

Indeed. See?
On purpose.

Fair enough.
 
D

dandelion


Of course. Pray forgive a typo.
Neither do I assume it. But I don't assume he's using ASCII
or a superset thereof, either.

I'd place a (modest) bet on that. That includes the ISO encodings,
so chances are (s)he does.
Well, not really. IBM mainframes, which are far from outdated, typically
use EBCDIC.

Hmmm...

Somehow I do not find the image of the OP using an IBM mainframe very
convincing...
Er, yes, actually.


Indeed. See?

I misread thinking you required a full charset to be implemented.
 
R

Richard Bos

dandelion said:
Yes.. Although i find 'a lot less' something of an exaggeration.

However, the assignment calls for comparisons of only a limited number of
values to check (spaces, newlines) and i'm not asking for character
conversion. I put in ASCII (7 bit) to prevent the student to take the easy
route and use 'isspace()', 'isprint()' and such.

Ah - so instead of learning to do the Right Thing, and use the functions
provided in <ctype.h> by every conforming implementation, you suggest
that students get learn to write their own, most likely non-portable,
inefficient replacements. I fail to see why this is advisable.
First write one yourself.
Should not be that hard, especially when restricted to only 128 symbols.

No char type is restriced to 128 symbols.
Besides, many encoding schemes (notably UTF-8 and ISO) have ASCII as a
subset and for UTF-16/UCS-2 (where you have to wonder about endianness) it's
the same.

And some do not.

Richard
 
D

dandelion

Ah - so instead of learning to do the Right Thing, and use the functions
provided in <ctype.h> by every conforming implementation, you suggest
that students get learn to write their own, most likely non-portable,
inefficient replacements. I fail to see why this is advisable.

It is good practice to implement some of the easier stuff yourself.
Electronics engineers in training start with resistors, capacitors and
transistors instead of complete IC's, latin students start with little,
simple sentences instead of Tacitus Historiae or Annales. Afterwards you can
point out the problems, inefficiencies and non-portabilities. But first let
them have a try at it themselves and see how they do.

Portability is a concept, i would introduce at a later stage. First learn to
do the basics, then worry about all kinds of other issues. Do not drown the
student in detail. Besides, i'd,let the student develop an idea of "The
Right Thing" of his/her own, instead of preaching it as a dogma. The RIght
Thing, after all, is something that flows from the practicalities of
programming, it's not something ordained by Ye Gods of Programming.
No char type is restriced to 128 symbols.

Not the char type. 7 bit ASCII.
And some do not.

True.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,157
Messages
2,570,879
Members
47,414
Latest member
djangoframe

Latest Threads

Top