Multiple return values...

Manu turkeyman at gmail.com
Thu Mar 8 16:40:07 PST 2012


On 9 March 2012 02:26, bearophile <bearophileHUGS at lycos.com> wrote:

> Manu:
> 7
> > How is any programmer supposed to intuitively assume that returning a
> tuple
> > by value would behave in that way? And how are you supposed to trust it?
> > It's an abuse of concept and syntax. It seems like a convolution that
> could
> > only possibly confuse people, they are conceptually quite different
> things,
> > and shouldn't be lumped into the same syntax for my money.
>
> I am asking for multiple return values in D since some years, so I share
> your desire. But keep in mind that in D currently there are Phobos Tuples
> and DMD typetuples. Adding a third type of tuple-like things in a single
> language sounds a bit excessive. Two kinds of tuples in a language are
> already too much, in my opinion.
>

This is most certainly NOT a tuple-like thing. I don't think I can stress
that point any harder :)
It is not an object, you can't evaluate it as a whole, you can't iterate
it, these values are not connected in ANY way. These are the properties
which make the whole concept simpler, and intuitively map to the same
concept as passing multiple args TO a function, but in reverse. No tricks,
completely intuitive and predictable.

You aren't expected to construct an arg list tuple every time you want to
CALL a function, you just line up a sequence of values you get from
wherever. Multiple return value assignment should be just as random and
flexible; eg, one item stored to memory, one retained as a local (kept in a
register with no memory expression), another may be ignored (stripping
associated code path)...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120309/ceaa3e4b/attachment.html>


More information about the Digitalmars-d mailing list