Re: A question about certain language features

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

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

Hi Derek Parnell, you wrote on 3/21/02 12:27:45 PM:

>
>Karl,
>I'm thinking that a distinct token be placed in the slice notation that
>indicates end-of-sequence rather than omitting the end slice value. Maybe a
>"$" symbol.
>
>    foo = "abcdefghij"
>    a = foo[2..$]    -- everything except the first element.
>         a==> "bcdefgihj"
>    b = foo[1..$-6] -- everything except the last 6 elements.
>         b==>"abcd"
>    c = foo[$-4..$-1] -- only the elements 6 thru 9.
>         c==>"fghi"
>
>The problem with omission is that it you are never certain that the
>omission
>was deliberate or not. A specific symbol inserted is more rarely a mistake.
>Of course we don't need a special symbol to represent the beginning of a
>sequence because the value 1 suffices.

I much prefer '$' to '0' for this purpose. It seems that this introduces
a 'Perl-ish' pseudo-variable into the language. '$' is defined as:
'length(<most-recent parsed sequence>)'. We could then have:
  sequence s
  s = foo();
  ?$		-- print length of s
The possibilities are endless!

>The other nice slice extention is to allow a list of subslices in the
>notation:
>
>   d = foo[1..3, $-2..$]
>      d==> "abchij"
>
>but that might be stretching the friendship blink

Maybe later blink

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