From: Jean-Hugues ROBERT Date: 2002-04-29T03:44:53+09:00 Subject: Re: $_ if no |var| Hello, At 06:16 28/04/2002 +0900, Lars Christensen wrote: >I think I would 'expect' all assignments to be >made. I.e. > proc { if |a| then |b| else |c| end } >should only be syntatic sugar for > proc { |a,b,c| if a then b else c end } >or, equivalently > proc { |p| a,b,c=p; if a then b else c end } >The |a| would just be syntax to mark which symbols should be bound to the >arguments when the block is evaluated. >I would also expect > proc { if |a| then |b| else |c|+b end } >to work, except in more complex cases, i'd use the current syntax. This makes sense. The definition of the || construct would then be something like: Within a block, some variables may be enclosed within ||. These variables will be assigned the block parameters when the block evaluation starts. The assignment order is independent of the actual value of the parameters, it follows the order in which || enclosed variables appear in the block's source code. A block usually starts with the || enclosed list of variables, however it is sometimes more convenient to have multiple || for readability purposes only. When only one variable is || enclosed, it is assigned an array containing the parameters, unless there is only one parameter or a comma was specified before the terminating |. This later case generate an ArgumentError when more than one parameter is passed to the block. This also happens whenever the number of parameters does not match the number of || enclosed variables. Nota: This is the "compile time" approach. Yours, Jean-Hugues ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17