On Sun, 11 Nov 2001, Alex Gough wrote:

(but not quite enough...)

> On Sat, 10 Nov 2001, Jeff wrote:
> 
> > string.pasm patches the operators mentioned
> > The other file, 'parrot.pasm', is a miniature Parrot compiler, written
> > in Parrot.
> > 
> > The patches in the string.diff file are required to make this work.
> 
> ook, cool, but string_length returns an INTVAL, not an int.

Remember that people who say "negative" usually mean "positive", they
just don't know it yet.  Always look on the bright si-ide of life, de
do, de do de do de do.

Yes, also this doesn't follow the style of the rest of string.c
(s->strlen is your friend) and I'm not sure that (char*)[index]
is the right way to get ord for $encoding.

Have we actually worked out what ord should do yet?

string_ord should be more like this anyhow:

INTVAL
string_ord(STRING* s, INTVAL index) {
    if(s==NULL) {
        INTERNAL_EXCEPTION(ORD_OUT_OF_STRING,
                           "Cannot get character from empty string");
    }
    else {
        if (index < 0 ) {
            index = s->strlen + index; /* zero based */
        }

        if (index > (s->strlen - 1) || index < 0) {
            INTERNAL_EXCEPTION(ORD_OUT_OF_STRING,
                               "Cannot get character outside string");
        }
        else {
            /* WORK OUT WHAT ORD SHOULD BE */
        }
    }
    return -1;
}

Also, is it wise to be #defining every one of our errors to be 1,
aren't these better being an enum, or is there merely not yet a plan
for exceptions that works?

(The general gist of the patch is damn good, btw)

Alex Gough


Reply via email to