Paul Hodges wrote:
--- Spider Boardman <[EMAIL PROTECTED]> wrote:
You need ord() for character/grapheme/byte/whatever testing that's
equivalent to what C does.  Since C doesn't really have strings, and
Perl does, this is just one of those differences between the
languages where (essentially, and perhaps abusing some linguistics
theory and terminology) you've run into a 'false cognate'.

lol -- C doesn't have strings, but Perl does?

He's absolutely correct.

C does not have a string type, just as Perl does not have a character type. In C you can *represent* a string as an array of characters, just as in Perl you can *represent* a character as an integer. But there's no built-in, native type for either of these.

You could write your own data structure to represent a string (Parrot, Perl 6's runtime engine, does this), but it's still not a first-class, built-in type the way an int or float or char is. You wouldn't be able to compare it with < or have it behave rationally as the condition of an if() or copy it with =. (You could do all of these things with C++, though--but it still wouldn't be a built-in type.)

Similarly, you could write a class to represent a character in Perl 6, but it wouldn't be built-in like Int, Num and String are. It could come very close--it could work correctly (for some value of "correctly") in boolean context, for example, unlike C strings--but it would still require a "use" statement to get at, and people often wouldn't design their modules to use it the way they do for Int, Num and String.

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

Oceania has always been at war with Eastasia.

Reply via email to