Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: A comment to Carl's blog

From: ammon::johnson::gmail::com at: 21-Oct-2004 0:14

Interesting comments Anton, however, I can't see how any of this could work... data/:(n: 150 'n) Here you have a Get-Paren. What's a Get-Paren? Parens are automatically evaluated.... data/(index + 2) The equivelant to that would be... pick data index + 2 since index wasn't given a value then it would throw an error. Here's how I see this new path notation being used... data: [Bob Hope "1234 Hope St."] firstname: 1 lastname: 2 address: 3 data/:firstname: 'John data/:lastname: 'Doe data/:address: "4321 Doe St." It is mostly to obtain a little more clarity in your code. Compare the above with this... data: [Bob Hope "1234 Hope St."] data/1: 'John data/2: 'Doe data/3: "4321 Doe St." The ability to use a Get-Set-Word in a path was actually one of my first feature requests when I started using REBOL, as was the ability to put a paren in the path. Now that is one really powerful feature. ;-) Simple examples simply don't show how much clarity these features can provide in your code. Start doing some extensive block work with it and I think that you will be amazed at how clear your code is... HTH ~~Ammon ;~> On Thu, 21 Oct 2004 16:38:57 +1000, Anton Rolls <[antonr--lexicon--net]> wrote:
> Well, I agree it is a bit ambiguous, > but if you think that rebol operates > left to right, then you can see that > the get-word :n happens before the set-word n: > > The second possible meaning: > I imagine if it was wanted that way, you could > be able to write: > > data/:(n: 150 'n) > > or > > data/(150) > > since you already know the value of n > or know how to calculate n. > I don't see it's very useful to set 'n just to > be used as a temporary value in a path. > > However, it got me thinking... > Perhaps temporary variables could be used further down > the path. ie. > > data/(n: 150)/(n + 1) > > is equivalent to: > > data/150/151 > > Another idea is perhaps if data is a block which contains > a name/value pair, then you could access 'name inside the > parens. eg: > > data: [index 3 a b c d e] > data/(index + 2) > ;== c > > or > > data: [header 4 index 3 a b c d e] > data/(header + index) > ;== c > > Just some ideas. > > Anton. > > > Hi, list, > > > > About http://www.rebol.net/blog/carl.html#section-5 > > > > Here's Carl's exemple: > > data: [10 20 30] > > n: 3 > > > > This shorthand for accessing elements in blocks is added to rebol version > > 2.5.55: > > data/:n: 150 > > > > But then: is it absolutely clear that this should mean > > poke data n 150 > > > > Couldn't it just as well mean: > > n: 150 > > pick data n > > > > i.e. with the form > > :n: > > which should be evaluated first, :n or n: ? > > > > This might be a dumb question, but I don't see that this is all > > that clear. > > Elucidate me! > > > > A copy of this email is sent via http://www.rebol.com/contacts.html. > > > > HY > > -- > To unsubscribe from the list, just send an email to rebol-request > at rebol.com with unsubscribe as the subject. >
-- Enjoy!! ~~Ammon ;~[) ~Sui Generis~