> While I understand that in some cases parens may be necessary to avoid ambiguities, in the following example I fail to see why they are needed : > > this simply prints the list of files in the current folder and works quite fine : > > >> foreach elt read %. [if (get in info? to-file elt 'type) = 'file [print elt]]
> but when removing the parens we get : > > >> foreach elt read %. [if get in info? to-file elt 'type = 'file [print elt]] > ** Script Error: in expected word argument of type: word > ** Where: halt-view > ** Near: if get in info? to-file That's because the '= is infix; it grabs the left and right arguments, as it were. Try this instead: foreach elt read %. [if 'file = get in info? to-file elt 'type [print elt]] Andrew Martin ICQ: 26227169 http://valley.150m.com/ -><- ----- Original Message ----- From: "Laurent Giroud" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, October 06, 2002 10:30 AM Subject: [REBOL] if and parens > Hi everyone again, > > I have a little "problem" that I encounter quite frequently with 'if : in > certain cases I need to use parens to make sure that the expression tested is > correctly evaluated. > While I understand that in some cases parens may be necessary to avoid > ambiguities, in the following example I fail to see why they are needed : > > this simply prints the list of files in the current folder and works quite fine : > > >> foreach elt read %. [if (get in info? to-file elt 'type) = 'file [print elt]] > ... > > but when removing the parens we get : > > >> foreach elt read %. [if get in info? to-file elt 'type = 'file [print elt]] > ** Script Error: in expected word argument of type: word > ** Where: halt-view > ** Near: if get in info? to-file > > The code looks quite unambiguous to me since all the part beetween the 'if and > the "=" character evaluates without problem if isolated : > > >> elt: %afile ; "afile" being an existing file > >> get in info? to-file elt 'type > == file > > Would anyone have an explanation ? > > Regards, > Laurent > > -- > Laurent Giroud > mailto:[EMAIL PROTECTED] > > -- > To unsubscribe from this list, please send an email to > [EMAIL PROTECTED] with "unsubscribe" in the > subject, without the quotes. > -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.
