From: Ronald Fischer Date: 2007-05-25T16:58:08+09:00 Subject: Re: Introducing the "it" keyword > This is obviously suboptimal code, as is, because it results in the > evaluation of m(x) twice. I propose a new keyword is added, "it", > which may appear within the statement to the left of the decorator. > So, the previous statements become: > > puts "User: #{it}" if opts[:user] > > and > > return it if |v + 1| < 10 IMO, this is a special case of the more general idea that within a certain piece of code, the value of an expression needs to be refered to more offen. Looking at how others do this, the functional programming / Scheme people usually handle it with a 'let' construct: let v = opts[:user] in puts "User: #{v}" if v Of course this has the disadvantage that we *have* to invent a new name (v). But assuming that such a substition is only done locally, we could as well use placeholders. 'it' would be such a placeholder, kind of: let opts[:user] in puts "User: #{it}" if it but this would restrict us to have only one binding at any time. A more general solution could be like this: let a+b+c in let foo=d*e in let x/y in puts ($1+foo)*($1-$2)-$2/($1-foo) Here, $1 would be bound to x/y (innermost unnamed let binding), $2 would be bound to a+b+c (second innermost unnamed let binding). This is similar to the binding of parameters in the DeBrujin Lambda calculus, if my rusty memory is right (any FP people here who can comment on this?). Of course it does not mean that the notation $n is really good here (as it is already taken by a different usage), but one could equally well think of other ways to denote this, such as _1 or \1 or whatever it is seen practical. Ronald -- Ronald Fischer Phone: +49-89-452133-162