Multiple return values

Manu turkeyman at gmail.com
Wed Jan 4 00:36:24 PST 2012


I only base my expectation on the fact that D is an open source language
maintained by a community that comes from many other areas of programming,
has a tendency to respond to user feedback, and generally seems to do it's
best to cherry pick the best bits from virtually every other language I can
think of. I'm just surprised this isn't constantly requested, and I see no
harm in adding it.
I'm sure an unambiguous syntax can be invented (although I don't like the
current proposal using EVEN MORE parentheses)... D has a bit of an
obsession with parenthesis... ;)

Regardless, I'd like to put a strong +1 towards proper multiple return
values. The point is NOT just to have the syntactical feature (ie. struct
return value semantics via tuples). The point is a language guarantee that
the architecture will do its best job to return each value in consecutive
registers OF ITS OWN TYPE, avoiding allocation&writing to the stack. This
is a common problem in C where the only solution is to make functions
inline or pay the cost of hitting the stack (LHS hazard, very expensive on
many RISC architectures).
It would lead to many optimisations in lots of code in my experience.

On 4 January 2012 05:46, Jonathan M Davis <jmdavisProg at gmx.com> wrote:

> On Tuesday, January 03, 2012 19:48:53 bearophile wrote:
> > Jonathan M Davis:
> > > I'm not saying anything about the value of the feature. I'm just saying
> > > that given D's lineage, it's not at all suprising that it doesn't
> > > support multiple return values. In fact, it would be very abnormal if
> > > it did. The OP seems to expect that modern languages would support such
> > > a feature, whereas many do not - particularly the C-based ones.
> >
> > OK.
> > For fun here is a slightly modified version of your text:
> >
> > "I'm not saying anything about the value of the feature. I'm just saying
> > that given D's lineage, it's not at all suprising that it doesn't support
> > nested functions. In fact, it would be very abnormal if it did. The OP
> > seems to expect that modern languages would support such a feature,
> whereas
> > many do not - particularly the C-based ones."
> > :-)
>
> Well, yeah. Having nested functions in C-based languages is not normal,
> and I
> don't believe that most other "modern" languages have them either, so it's
> arguably unreasonable to _expect_ that D would have nested functions,
> because
> it's a modern language. That doesn't mean that it _won't_ have nested
> functions (or multiple return values), but _expecting_ that it will simply
> because it's a modern programming language is arguably unreasonable.
>
> - Jonathan M Davis
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120104/45e9954b/attachment.html>


More information about the Digitalmars-d mailing list