Re: compare , zero indexing (Re: mainly syntax)

new topic     » goto parent     » topic index » view thread      » older message » newer message

> No, I don't think so. Compare() returns three values: less than,
> equal, greater than. = only two: equal, unequal.
>
> What threw me off is that  "if x=y"  reports an error
> when x and y are strings, and that compare() returns
> -1, 0, or 1.  Me, simple-minded linguist that I am,
> I have written myself compare functions in Pascal before,
> but I had them return '<', '=', and '>'!

Yay, another linguist (syntactician, actually smile! Anyway, compare() or
the equivalent in a lot of languages also returns -1, 0 and 1. Perl
uses the 'cmp' or '<=>' operators; and most languages, when they ask for a sort
function to sort an array through, expect it to return -1, 0 or 1 (Perl,
uLPC/Pike, LPC do this, probably others).

> Except Pascal, ALGOL, Simula, Ada, Modula, and, I imagine, others
> I do not know about, which start counting from whatever you tell
> them. I am quite happy with counting from 1 in Euphoria, I am
> not a Mayan, you know (they counted the days of the month
> from zero).

Actually, BASIC doesn't have to, surprisingly. At least on C64s, you can
start assigning to arrays at element 0, although it's uncommon. I would
expect most Microsoft 8-bit BASICs, like Applesoft and Atari Microsoft BASIC,
did the same.

> I agree there. I had been looking for something like that in the
> reference library and the manual, and was surprised not to find
> anything. I thought it was myopic me.

Perl has a whole raft of signal handling features. You can have a __DIE__
trap to hook fatal errors -- even compile-time ones (!), and while DOS
Euphoria doesn't have much call for trapping SIGALRM, it might in a
Unix version smile)))).

--
Cameron Kaiser * spectre at sserv.com * http://www.sserv.com/
--
Visit the leading Internet starting point today!
http://www.sserv.com/
--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu