On 10/3/2012 11:50 PM, Jacob Carlborg wrote:
On 2012-10-04 01:33, Alex Rønne Petersen wrote:

> Use tuples. Multiple return values (as far as ABI goes) are impractical
> because every major compiler back end (GCC, LLVM, ...) would have to be
> adjusted for every architecture.

Why can't it just be syntax sugar for returning a struct?


That's really the only credible way. A tuple should be an anonymous struct with the fields being the elements of the tuple.

The main issue for me for having perfect tuples is that the layout of fields in a struct is different from the layout of parameters being passed on the stack to a function. Ideally,

   struct S { int a; int b; }
   void foo(int p, int q);
   S s;
   foo(s);

should work (setting aside for the moment that they are different types). Unfortunately, the variety of function calling ABIs makes this impractical.

So tuples in a language like D that must conform to external ABIs is that tuples will always have some rough edges.

Reply via email to