Multiple return values...
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed Mar 14 12:08:46 PDT 2012
On 3/14/12 2:02 PM, Ary Manzana wrote:
> On 3/13/12 6:12 PM, Andrei Alexandrescu wrote:
>> On 3/13/12 2:57 PM, Manu wrote:
>>> And you think that's more readable and intuitive than: (v1, v2, v3) =
>>> fun(); ?
>>
>> Yes (e.g. when I see the commas my mind starts running in all directions
>> because that's valid code nowadays that ignores v1 and v2 and keeps v3
>> as an lvalue).
>
> Who uses that, except code generators? I'd like D to deprecate the comma
> so it can be used for other things, like tuple assignment.
I'd like that, too, but we need to worry about breaking code, too.
>> Let me put it another way: I don't see one syntax over another a deal
>> maker or deal breaker. At all.
>
> Well, it's sad that syntax is not very important in D.
That's an undue generalization of what I said.
> If you have to
> write less code there will be less chance for bugs and it will be more
> understandable (unless you obfuscate the code, obviously).
I agree.
> Here's what you can do in Ruby:
>
> a = 1
> b = 2
>
> # Swap the contents
> a, b = b, a
>
> Can you do something like that with templates in D, with a nice syntax?
swap(a, b)
Andrei
More information about the Digitalmars-d
mailing list