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

[REBOL] Re: The evaluation semantics

From: lmecir::mbox::vol::cz at: 3-Sep-2005 18:44

Henrik Mikael Kristensen napsal(a):
>On Aug 30, 2005, at 9:50 AM, Behrang Saeedzadeh wrote: > >>Hi >> >>I'm kinda new to REBOL. Actually I was a member of this list about two >>years ago and I was registered with my Yahoo! account. I felt like >>that I'm really missing REBOL so I've joined the list once again :-) >> >>In the online manual at >>http://www.rebol.com/docs/core23/rebolcore-3.html it's written that: >> >>"The values and words of a block are always evaluated from first to >>last... >>" >> >>So I expected the following statement, without the parantheses of >>course, return 6 but it is erroneous: >> >>length? "boat" + 2 >> >>Can someone please explain the reason behind this behaviour? >> >> > >That's because length? "boat" returns it's value to the physical left >of itself, e.g.: > >4 <- length? "boat" > >and not > >length? "boat" -> 4 > >+ requires a value on each side where the one on the left, returns a >value to its right, e.g.: > ><value> -> + <- <value> > >but your statement produces: > ><- <value> + <- <value> > >The (very) new Wikibook has a bit about this, actually: > >http://en.wikibooks.org/wiki/ >Programming:REBOL#Simple_Programming_in_the_Console > >The part about parentheses is not entirely accurate yet, but it >should fit with what you need. > >-- >Regards, >Henrik Mikael Kristensen >
Actually, the reasoning is different. The fact is, that the + operator has precedence over the length? function. Therefore the first opearation the interpreter tries to evaluate is: "boat" + 4 , which results in an error. -L