RE: A question about certain language features

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

-------Phoenix-Boundary-07081998-

You wrote on 3/21/02 10:54:37 AM:

>Karl,
>
>   Consider this syntax for shorthand slicing. Your current syntax sort
>of defeats the sequence bounds checking.
>
>seq[1..0] -- seq[1..length(seq)]
>seq[1..0-1] -- seq[1..length(seq)-1]
>
>seq[1..1-1] -- {} (reverse slice)
>seq[1..-1] -- index [-1] out of bounds
>
>integer index   index=0
>seq[1..index] -- {} (reverse slice)
>
>'O' is explicit, it cannot be implied. If it is, the original EU rules
>apply.
>
>I haven't thouroughly looked. Does your shorthand work if it's implied
>with a variable?
>
>
>Chris

I handle 'foo[2..]' by expanding it textually. I think of it
as a macro.

when I see the '..' followed by a ']' or '-', I insert the text
'length(foo)' directly into the input stream. (Having previously
saved the 'foo').
'foo[2..]' causes the interpreter to actually see 'foo[2..length(foo)]'
and 'foo[2..-(a*b)]' is seen as 'foo[2..length(foo)-(a*b)]'


As a result, all the normal Euphoria processing is left intact.

Thanks for the link
Karl Bochert

-------Phoenix-Boundary-07081998---

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

Search



Quick Links

User menu

Not signed in.

Misc Menu