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

[REBOL] Rebol/Core User's Guide Re:(4)

From: lmecir:geocities at: 11-Oct-2000 20:38

Hi Joel, you wrote:
> Hello again, Ladislav, > > [lmecir--geocities--com] wrote: > > > > Hi Joel, > > > > I knew about that issue, but considered the Throw attribute as
absolutely
> > necessary in this case... > > > > Certainly! I've been reading a fascinating essay by Richard Gabriel on
the
> power (and dangers!) of abstraction, and will likely mutter about that in > a later post. > > > You are right. To be correct, it should have been like > > this: > > > > ifs: func [ > > {If positive do block 1, zero do block 2, minus do 3} > > [throw] > > condition [number!] > > block1 [block!] > > block2 [block!] > > block3 [block!] > > ] [ > > either positive? condition [do block1] [ > > either negative? condition [do block3] [do block2] > > ] > > ] > > > > Well, I was as surprised as you will be by the following behavior: > > >> ifs: func [ > [ {If positive do block 1, zero do block 2, minus do 3} > [ [throw] > [ condition [number!] > [ block1 [block!] > [ block2 [block!] > [ block3 [block!] > [ ] [ > [ either positive? condition [do block1] [ > [ either negative? condition [do block3] [do block2] > [ ] > [ ] > >> ifs b ["positive"] ["negative"] ["zero"] > == "positive" > >> ifs b ["positive"] ["negative"] ["zero"] > == "zero" > >> ifs b ["positive"] ["negative"] ["zero"] > == "positive" > >> ifs b ["positive"] ["negative"] ["zero"] > == "zero > > I had expected that the argument type check would barf on my little > pathological case, but it didn't!!!!! >
You should read exception #5 for word evaluation of my Rebol/Core User's Guide Comments to understand the behaviour. The fact is, that Ifs really gets a number and there is no need to worry about any change during the Ifs evaluation in the case you supplied and, moreover, if Ifs is defined as above, no such bug is lurking behind the scenes.