From: Mathieu Bouchard Date: 2002-01-15T02:56:02+09:00 Subject: Re: a wishlist for ruby 2.0 On Mon, 14 Jan 2002, Daniel Berger wrote: > "Hal E. Fulton" wrote: > > From: "David Alan Black" > > > On Mon, 14 Jan 2002, Mathieu Bouchard wrote: > > > > * syntax: make foo.bar(2,3,5)=7 mean foo.bar=(2,3,5,7) > > > What's the reasoning behind that? > > Not to speak for matju, I can see a logic behind this. > > I think he wants to let bar= have other arguments > > besides the single argument. > That would be considered an lvalue sub, right? How do most other > languages handle this? Or is there a consistant behavior among > languages? there is no consistent behaviour among languages. In C++ it is done by making the return type a lvalue type (append a &). In Perl this is a version 5.6 feature (I know only Perl 5.4/5.5), and works mostly like in C++. In CommonLISP, there's a special DEFSETF form that looks alot like DEFUN but has an additional argument separate from the main argument lisp. CommonLISP's object system is inconsistent (and possibly better) in that instead the method name can be either a Symbol or a list like (SETF method-name), e.g. (defmethod (setf my-blah) ((my-class self)) (my-other-blah (my-frob self))) which in Ruby is: def my_blah value my_frob.my_other_blah = value end but Ruby doesn't support additional arguments, while CommonLISP does. Imho it's useful when you want several methods like #[]=, but can't because #[]= is the only name you can give it. ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju