Multiple return values...
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Mar 15 10:05:00 PDT 2012
On 3/15/12 11:30 AM, Manu wrote:
> On 15 March 2012 17:32, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org <mailto:SeeWebsiteForEmail at erdani.org>>
> wrote:
> One note - the code is really ingenious, but I still prefer swap()
> in this case. It's more concise and does less work in the general case.
>
> swap(a[i + k], a[j + j]);
>
> only computes the indexing once (in source, too).
>
>
> It all still feels to me like a generally ugly hack around the original
> example:
> a,b = b,a;
It's a function call. Why is a function call a ugly hack?
It's also more verbose. Compare
swap(a[i + k], a[i + j]);
with
a[i + k], a[i + j] = a[i + j], a[i + k];
I mean one could even easily miss a typo in there.
There's also semantic issues to be defined. What is the order of
evaluation in
f(), g() = h(), k();
?
All of this adds dead weight to the language. We shouldn't reach to new
syntax for every single little thing.
Andrei
More information about the Digitalmars-d
mailing list