From: Kristof Bastiaensen Date: 2004-04-28T06:54:12+09:00 Subject: Re: Semantics of Multiple Values (updated RCR) Hi, On Wed, 28 Apr 2004 04:51:59 +0900, Jean-Hugues ROBERT wrote: > > "unify" and "assign" work even better if a new type of > value is introduced (in addition to the one introduced already, > the one that is a & reference to a variable). > > The new type is "FreeClass", much like TrueClass. That is > a Singleton too. > > Q. What is it for ? > A. a = FreeClass.instance() is the way to "free" the "bound" > variable named "a". Shorthand: a = free This type already exists: NilClass, with as only instance nil. In fact nil is always used for unbound variables. Whenever a variable isn't bound, it evaluates to nil, for all variables (global, object) except local. Local variables are the only ones that can raise an error, the reason for this is that local variables and methods or interchangeable. Whenever Ruby sees a local variable that didn't have an assignment before, it treats it as a method call. When at runtime it executes the method, and cannot find it, it will give an error. I would suggest using := as a unification operator. Ruby could then always see that what is before the operator are variables. It would treat nil as the unbound. I am still not really convinced of the practical use of this operator. I can see one usage, as initialization: a := 0 #meaning a = 0 if (a == nil). perhaps the following def search_data some_operation return succeed, value1, value2 end a, b = nil if true, a, b := search_data end #but you may as well use succes, a, b = search_data if(succes) end There may be other real world practical uses, but I cannot think of any. Any suggestions?