From: Matthew Moss Date: 2008-12-13T07:29:44+09:00 Subject: Re: parallel method return value On Dec 12, 2008, at 4:12 PM, Louis-Philippe wrote: >> Now, you want a to be 1, but Ruby would need the power to read >> minds to >> accommodate that. See, because if I do the same, I want a to be [1, >> 2, 3]. >> How is foo supposed to figure that out? Or why should your want be >> more/less >> preferable than my want? >> > > You're totally right Matthew, I was twisted into thinking assignment > would > do it for one lvalue with multiple rvalues... > Its probably a crazy idea, and who am I to have idea about language > design > without any means to implement them... Well, I shouldn't have said, "No, completely impossible." Other languages may do what you want. As far as Ruby goes, the options I see are: 1. Deal with it. 2. Change design/spec of Ruby to return multiple values instead of one array. (Serious work and impact.) 3. Have some sort of macro mechanism? (IE, where the call to foo would be inlined... perhaps then allowing parallel assignment). 4. Support something like a = *[1, 2, 3] to mean a, = 1, 2, 3. (Umm... hmm... dunno about that.) 5. Return a proxy? (This might not be any different from current situation.) 6. Lambda/procs? 7. Make a a proxy/class/wrapper that does what you want. My guess is that #1 is current situation, #2 and #4 won't happen, #3 I've no idea, #5 is no different than #1, and #6-7 I'd have to spend some time thinking about. Maybe others have ideas on those.