Re: mainly syntax; to Robert

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

At 06:50 PM 98/02/18 -0500, Rob wrote:

>> x[a..length(x)]
>
>A couple of years ago I almost went ahead and
>implemented the thing Pete recently suggested:
>    x[a..]
>i.e., leave off the second index of the slice and it means
>"length(x)" by default. I went a step further and thought
>that
>   x[..b] should mean x[1..b]
>Then I got tired of the whole idea - why can't someone
>type in "1"? Isn't 1..b going to be more readable and only
>*one more keystroke?* I moved on to other things.
>

i'm sure that x[a..] will provide very handy tip to all Euphoria user,
dear Robert, please go ahead implement it!!!!

however, x[..b] implementation should be quite useless. since the first
element in a sequence starts ALWAYS from 1. it's a CONSTANT.

i feel that you too much stick to the idea of something like
"generality" of the syntax...

But please note that x[a..] and x[..b] are quite differnt cases. we have
to call length() function every time to know the length of sequence,
and the length of sequence is usually variable...
but the first index number is always 1, CONSTANT.

i personally prefer Pete's suggestion x[a..] to the David's x[a..end].
Of course, using 'end' may have some merit like x[a..end-3]. however,
when we use the 'index offset from the end of sequence', the length
value is usually to be used at the followed parts of code, and it's better
to assign the length to a varible... (based on my own experience)

x[a..] is nothing more than "a handy tip" (very handy tip). Therefore,
don't take it be so serious.... Don't try go too further...

Sorry for my "crashed" english...

Bye! from Lee, woo seob.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu