Multiple return values...

Ary Manzana ary at esperanto.org.ar
Wed Mar 14 12:02:50 PDT 2012


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.

>
> 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. 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).

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?


More information about the Digitalmars-d mailing list