Trass3r:
> > This shows why built-in tuples are good.
> What do tuples have to do with that?

According to D2 semantics that program2 is correct, because in D you can use 
variables that are not initialized by the programmers. But the spirit of that 
program2 is trash anyway, because it reads the value of a variable that's meant 
to be used as return value only, so it's meant to be written before any read.

In a situation like program2 the C# compiler prints an error like:
error CS0269: Use of unassigned out parameter `x'
Because in C# it is not allowed to use uninitialized variables. This is a so 
tidy thing (bug probably such tests done by C# compiler forbids some correct 
spaghetti code that D doesn't forbid. It's hard to find such cases in normal C# 
programming).

So I think 'out' arguments are bug-prone in D. If you have tuples, you can 
return one of them avoiding the need for 'out' arguments (they can even be 
removed from the language), so you can avoid some possible bugs.

Bye,
bearophile

Reply via email to