Re: A question about certain language features
- Posted by Derek Parnell <ddparnell at bigpond.com> Mar 21, 2002
- 636 views
Chris, I see we are thinking alike here. I suggested the '$' symbol because that is often used in regular expression syntax to mean the end-of something. The symbol '0' could also be a coding mistake, but I would think a rare one (eg. I miskeyed the '9'). Also, it doesn't seem to be associated with "end-of", except maybe a count-down by NASA. a = foo[2..0] -- is what I keyed, a = foo[2..9] -- but this is what I meant. ------- Derek ----- Original Message ----- From: <bensler at mail.com> To: "EUforum" <EUforum at topica.com> Sent: Friday, March 22, 2002 8:00 AM Subject: RE: A question about certain language features > > Your syntax, and the form that I am suggesting are virtually identical. > The difference is in readability, and ease of implementation. > Compare: > foo[1..] == foo[1..length(foo)] > foo[1..-1] == foo[1..length(foo)-1] > > foo[1..0] == foo[1..length(foo)] > foo[1..0-1]== foo[1..length(foo)-1] > > Your implementation requires 2 checks for substitution. > My suggestion is to simply subtitute the literal '0' with length(foo) > > foo[1..] could just be a typo. > foo[1..0] is defined explicity. > > Yes, my example could be a typo also, but not as likely to happen. > > foo[1..-1] the negative could be fairly easily missed. > foo[1..0-1] knowing that the literal '0' is always substituted with > length(foo), it's easy to see the intention. > > > To summarize, your implementation adds two new rules, whereas my > suggestion only adds one. > The concepts are identical, but the representation is different. > > > Chris > > kbochert at ix.netcom.com wrote: > > -------Phoenix-Boundary-07081998- > > Content-type: text/plain; charset=ISO-8859-1 > > Content-transfer-encoding: 8bit > > > > 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--- > > > > > >