Re: [code] interpreter.c headaches from "George" at Oct 5, 97 10:06:37 am

From: Andrew Helm (ashe@IGLOU.COM)
Date: 10/05/97


>
> On Sun, 5 Oct 1997, Andrew Helm wrote:
>
> >It all started innocently enough. I noticed that skip_spaces()
> >did something unintuitive: it increments the pointer passed
> >to it in order to skip the spaces at the beginning of the string.
>
> It's a very good way of doing it so long as you're not trying to call
> free() on that block pointer to later. (But then it's bad practice for a
> function to free() an argument when you don't know if it was dynamically
> allocated.)

Exactly. It will also slowly eat away at max size of the string you
call it on. It's not immediately obvious that it does this, and I'm
thinking of CircleMUD "newbie" coders (for lack of a better
term.) I think its more intuitive for skip_spaces() to modifiy
the string not the pointer to the string. Heck, even people
who know what they're doing can be caught by it. It's not at
all obvious unless you take the time to look up the skip_spaces()
function and see what it does for yourself.

> >What do you think the stock Circle behavior should be?
>
> Make something new up, if we like it better and it is more proper, we will
> probably switch.

Okay: how about you modify the string instead of the pointer?
The only problem is it breaks other stock functions.

> >lower case letters. In my opinion, it should be the
> >responsibility of "higher" functions (and hence putting the
> >responsibility in the end programmer's hands instead of
> >whoever coded the utility functions) like special procs,
> >ACMDs, etc. to decide if case sensitivity is desired. There
> >are exceptions, but functions that are "general utility"
> >functions shouldn't assume such things. Any opinions?
>
> str_cmp exists for insensitity, use strcmp if you want it sensitive.

Correct. What does this have to do with a significant portion of
the basic utility functions discarding case sensitivity and
sometimes permanently modifying the strings to lower case letters?

> The lowercaseing is there probably so people can type with the caps lock on
> if they really want to with having to hold down shift to type commands.

The end programmer has no control over the case sensitivity or the
lower casing of the arguments. Anything that uses search_block()
will be lowercased (permanently). That includes basic functions
like one_argument(), one_word(), etc. Once again, I have
CircleMUD "newbies" in mind. CircleMUD is built to be fairly
intuitive and workable for those people who are learning
the ropes of coding. Such a person depends on basic utility
functions like one_argument().


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST