* Nils Goesche
| (defun isupper (char)
| (char<= #\A char #\Z))
Despite all the good intentions and efforts to help this lost newbie, I think
it is a mistake to try to help people who ask such questions. (This reply is
not directed specifically towards Nils.)
Defining your own because the standard function does not have the same name
as in C is wrong. We already have upper-case-p, lower-case-p, alpha-char-p,
etc, in Common Lisp. Reinventing wheels to look more like C will do nobody
any good. Even asking for strlen and isupper is extremely counterproductive.
People who ask for help in Common Lisp but refuse to relinquish their past
language remind that I want to learn French, but only to hear it and read it.
The utter helplessness of most French-speakers' attempt to produce English is
so grating on my ears that I not only would like to be relieved of listening
to it, speaking their language to them would probably be just as atrocious
(almost like pronouncing "fromage" like "fromidge").
The original poster has no problem with strings, he has a problem with his
willingness to learn Common Lisp. Much could be said about this affliction
of the mind that causes people to assume that what they do not understand
does not matter, that they have reached such a level of omniscience that they
no longer need to observe and listen and learn. Having learned enough, some
people evidently stop learning altogether. What they learned first is the
standard for everything that comes later. That the probably only _truly_
random element in anyone's life is the order in which they experience things,
seems not even to be underststandable -- they somehow believe that the order
they run into them is universalizable and important, that first impressions
really tell you everything you need to know about something. I have seen
people who have the mental capacity only for the transition from "have not
experienced" to "have experienced", and who are unable to make a distinction
between their observations and their conclusions, such that they are unable
to change their conclusions about what they observed. They walk around like
they had CD-Rs for brains.
What is the length of a string? C's string representation has no room for an
allocated length vs an active length. C's string representation has no
concept of substrings. C's strings cannot contain all possible characters.
C's strlen is actually (position 0 <string> :key #'char-code) and is O(n).
Forget "strlen". For our immediate purposes, there is no "strlen". "strlen"
does not _exist_.
Common Lisp has vectors with fill-points, and strings are vectors which are
sequences and arrays. Numerous functions that in other languages only work
on strings, work on sequences in Commo Lisp. Functions like search, match,
find, position, etc, are much more general than string functions in other
languages. A string with a fill-pointer has a total and an active length.
Most sequence functions accept bounding indices, start and end indices that
make it possible to use substrings without modifying the target strings.
Common Lisp even has displaced arrays if you really need a substring without
copying the string contents. Common Lisp has string-streams to read from and
write to strings in memory. Common Lisp has real charcters, not just small
integers. Common Lisp's characters are not bytes, so when Unicode came
along, there was no need to make extensive library and language changes.
Common Lisp supports base and extended characters and hence base-string in
addition to the general string.
Common Lisp is a big-city language. Spit out the hayseed, pronounce "shit"
with one syllable and "shotgun" with two. You're not in Kansas, anymore. C
is the language of the poor farmer village where the allocation of every seed
and livestock matters, where taxes are low and public service non-existent.
Appreciating the value of a large language is evidently hard for many people,
just like many people find themselves miserable in the big city and go to
great lengths to create a small village for themselves in the city where
everything is like it used to be where they came from. Common Lisp can
accomodate people who want to program in any old language and re-create what
they are used to, but if they want to get the most ouf ot it, the only way to
do it is to adapt to the language and accept that somebody else may be better
than you are at designing languages.
Erik Naggum, Oslo, Norway ***** One manslaughter is another man's laughter.
Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.