Re: Multiple return values...

2012-03-16 Thread Iain Buclaw
On 16 March 2012 02:26, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/15/12 5:44 PM, foobar wrote: On Thursday, 15 March 2012 at 18:23:57 UTC, Andrei Alexandrescu wrote: I understand how the draw of reaching for new syntax is extremely alluring. I used to fall for it much

Re: Multiple return values...

2012-03-16 Thread Iain Buclaw
On 15 March 2012 17:51, Manu turkey...@gmail.com wrote: On 15 March 2012 19:05, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/15/12 11:30 AM, Manu wrote: On 15 March 2012 17:32, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote:  

Re: Multiple return values...

2012-03-16 Thread Artur Skawina
On 03/16/12 01:03, H. S. Teoh wrote: On Fri, Mar 16, 2012 at 12:11:44AM +0100, Simen Kjærås wrote: On Thu, 15 Mar 2012 23:44:09 +0100, foobar f...@bar.com wrote: Is swap usually inlined by the compiler? This is the body of swap for simple types: auto tmp = lhs; lhs = rhs; rhs =

Re: Multiple return values...

2012-03-16 Thread Manu
On 16 March 2012 04:26, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: A good design should strive to provide general features instead of special cases (E.g. swap is limited to the 2-tuple case). Also, why force an overhead of a function call on such a basic feature as assignment?

Re: Multiple return values...

2012-03-16 Thread Andrei Alexandrescu
On 3/16/12 6:29 AM, Manu wrote: On 16 March 2012 04:26, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote: A good design should strive to provide general features instead of special cases (E.g. swap is limited to the 2-tuple case).

Re: Multiple return values...

2012-03-16 Thread Iain Buclaw
On 16 March 2012 16:37, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/16/12 6:29 AM, Manu wrote: On 16 March 2012 04:26, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote:        A good design should strive to provide general

Re: Multiple return values...

2012-03-16 Thread Andrei Alexandrescu
On 3/16/12 3:48 AM, Iain Buclaw wrote: This could also be done for arrays too. (int a, b) = arr[]; - static assert(arr.length == 2); int a = arr[0]; int b = arr[1]; Yah, the rewrite is purely syntactic, not tuple-specific. That's a major thing I like about it. Or possibly a use in

Re: Multiple return values...

2012-03-16 Thread Andrei Alexandrescu
On 3/16/12 11:50 AM, Iain Buclaw wrote: If you were to forget all about MRV for a brief moment, the change request being proposed here is to return *all* structures (including delegates, complex types and vectors) in registers if at all possible even if the underlying ABI default is to return it

Re: Multiple return values...

2012-03-16 Thread Iain Buclaw
On 16 March 2012 16:53, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/16/12 11:50 AM, Iain Buclaw wrote: If you were to forget all about MRV for a brief moment, the change request being proposed here is to return *all* structures (including delegates, complex types and

Re: Multiple return values...

2012-03-16 Thread Manu
On 16 March 2012 18:37, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: Actually, as has been mentioned, swizzling can be done very nicely inside the language. How? The only example I saw in this thread was your from()/to() approach, which Timon said didn't actually work...? On

Re: Multiple return values...

2012-03-16 Thread Manu
On 16 March 2012 18:53, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/16/12 11:50 AM, Iain Buclaw wrote: If you were to forget all about MRV for a brief moment, the change request being proposed here is to return *all* structures (including delegates, complex types and

Re: Multiple return values...

2012-03-16 Thread Manu
On 16 March 2012 19:13, Iain Buclaw ibuc...@ubuntu.com wrote: On 16 March 2012 16:53, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/16/12 11:50 AM, Iain Buclaw wrote: If you were to forget all about MRV for a brief moment, the change request being proposed here is to

Re: Multiple return values...

2012-03-16 Thread Timon Gehr
On 03/16/2012 06:33 PM, Manu wrote: On 16 March 2012 18:37, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote: Actually, as has been mentioned, swizzling can be done very nicely inside the language. How? Use opDispatch. a = a.yxwz; The

Re: Multiple return values...

2012-03-16 Thread Manu
On 16 March 2012 19:53, Timon Gehr timon.g...@gmx.ch wrote: On 03/16/2012 06:33 PM, Manu wrote: On 16 March 2012 18:37, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:SeeWebsiteForEmail@**erdani.orgseewebsiteforem...@erdani.org wrote: Actually, as has been mentioned,

Re: Multiple return values...

2012-03-16 Thread Simen Kjærås
On Fri, 16 Mar 2012 03:26:55 +0100, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I think this is a reasonable request: (auto a, b) = fun(); --- static assert(fun().length == 2); auto __t = fun(); auto a = __t[0]; auto b = __t[1]; That would be nice. As was mentioned in a

Re: Multiple return values...

2012-03-16 Thread bearophile
Simen K.: Now, a pattern that our productive friend bearophile posted earlier was this: int[] foo(); (auto a, b) = foo(); --- auto __t = foo(); assert( __t.length 0 ); auto a = __t[0]; auto b = __t[1..$]; Is this something we might also want? That's not a good idea,

Re: Multiple return values...

2012-03-15 Thread Iain Buclaw
On 14 March 2012 22:06, Derek Parnell ddparn...@bigpond.com wrote: On Thu, 15 Mar 2012 08:52:26 +1100, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/14/12 3:00 PM, Simen Kjærås wrote: template to(T...) { alias T to; } auto from(T...)(T t) { struct Result { T t; alias t

Re: Multiple return values...

2012-03-15 Thread Timon Gehr
On 03/14/2012 11:06 PM, Derek Parnell wrote: On Thu, 15 Mar 2012 08:52:26 +1100, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/14/12 3:00 PM, Simen Kjærås wrote: template to(T...) { alias T to; } auto from(T...)(T t) { struct Result { T t; alias t this; } return Result( t );

Re: Multiple return values...

2012-03-15 Thread Derek
On Thu, 15 Mar 2012 19:23:57 +1100, Timon Gehr timon.g...@gmx.ch wrote: I'd like to break the nexus between science and magic here. // this is used to access language built-in tuples template to(T...) { alias T to; } // this builds a struct akin to std.typecons.tuple // it contains the

Re: Multiple return values...

2012-03-15 Thread Iain Buclaw
On 15 March 2012 09:52, Derek ddparn...@bigpond.com wrote: On Thu, 15 Mar 2012 19:23:57 +1100, Timon Gehr timon.g...@gmx.ch wrote: I'd like to break the nexus between science and magic here. // this is used to access language built-in tuples template to(T...) {     alias T to; } // this

Re: Multiple return values...

2012-03-15 Thread Andrei Alexandrescu
On 3/15/12 5:14 AM, Iain Buclaw wrote: On 15 March 2012 09:52, Derekddparn...@bigpond.com wrote: Are you saying that the generated code is something like ... struct __tmpS { int Fa, int Fb }; __tempS __tmp; __tmp.Fa = a; __tmp.Fb = b; a = __tmp.Fb; b = __tmp.Fa; In

Re: Multiple return values...

2012-03-15 Thread Manu
On 15 March 2012 17:32, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/15/12 5:14 AM, Iain Buclaw wrote: On 15 March 2012 09:52, Derekddparn...@bigpond.com wrote: Are you saying that the generated code is something like ... struct __tmpS { int Fa, int Fb }; __tempS

Re: Multiple return values...

2012-03-15 Thread Andrei Alexandrescu
On 3/15/12 11:30 AM, Manu wrote: On 15 March 2012 17:32, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@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

Re: Multiple return values...

2012-03-15 Thread Timon Gehr
On 03/15/2012 04:32 PM, Andrei Alexandrescu 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). In the general case,

Re: Multiple return values...

2012-03-15 Thread Manu
On 15 March 2012 19:05, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/15/12 11:30 AM, Manu wrote: On 15 March 2012 17:32, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:SeeWebsiteForEmail@**erdani.orgseewebsiteforem...@erdani.org wrote: One note - the code

Re: Multiple return values...

2012-03-15 Thread Andrei Alexandrescu
On 3/15/12 12:51 PM, Manu wrote: On 15 March 2012 19:05, Andrei Alexandrescu It's a function call. Why is a function call a ugly hack? Because now we're involving libraries to perform a trivial assignment. It's not a trivial assignment, it's swapping two pieces of data. This matter has

Re: Multiple return values...

2012-03-15 Thread foobar
On Thursday, 15 March 2012 at 17:05:00 UTC, Andrei Alexandrescu wrote: On 3/15/12 11:30 AM, Manu wrote: On 15 March 2012 17:32, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote: One note - the code is really ingenious, but I still prefer swap()

Re: Multiple return values...

2012-03-15 Thread foobar
On Thursday, 15 March 2012 at 18:23:57 UTC, Andrei Alexandrescu wrote: I understand how the draw of reaching for new syntax is extremely alluring. I used to fall for it much more often, but over years I have hardened myself to resist it, and I think that made me a better language designer.

Re: Multiple return values...

2012-03-15 Thread bearophile
Andrei Alexandrescu: generally the question is not why couldn't we add syntax X? but instead why should we add syntax X? You are right. Tuples are a basic data structure, some other language constructs are built on them (swapping items is just one of their purposes, then there is multiple

Re: Multiple return values...

2012-03-15 Thread Simen Kjærås
On Thu, 15 Mar 2012 23:44:09 +0100, foobar f...@bar.com wrote: Is swap usually inlined by the compiler? This is the body of swap for simple types: auto tmp = lhs; lhs = rhs; rhs = tmp; For more complex types: ubyte[T.sizeof] t = void; auto a = (cast(ubyte*) lhs)[0 .. T.sizeof];

Re: Multiple return values...

2012-03-15 Thread H. S. Teoh
On Fri, Mar 16, 2012 at 12:11:44AM +0100, Simen Kjærås wrote: On Thu, 15 Mar 2012 23:44:09 +0100, foobar f...@bar.com wrote: Is swap usually inlined by the compiler? This is the body of swap for simple types: auto tmp = lhs; lhs = rhs; rhs = tmp; For more complex types:

Re: Multiple return values...

2012-03-15 Thread Andrei Alexandrescu
On 3/15/12 5:44 PM, foobar wrote: On Thursday, 15 March 2012 at 18:23:57 UTC, Andrei Alexandrescu wrote: I understand how the draw of reaching for new syntax is extremely alluring. I used to fall for it much more often, but over years I have hardened myself to resist it, and I think that made

Re: Multiple return values...

2012-03-15 Thread James Miller
2. When was the last time you needed to swap arbitrary numbers of elements, and so badly and frequently, you needed a new language feature for that? Andrei I would like to point out Boscop's vector swizzling tutorial that he made recently as evidence that not only do you not need it that

Re: Multiple return values...

2012-03-15 Thread H. S. Teoh
On Fri, Mar 16, 2012 at 04:46:52PM +1300, James Miller wrote: 2. When was the last time you needed to swap arbitrary numbers of elements, and so badly and frequently, you needed a new language feature for that? Andrei I would like to point out Boscop's vector swizzling tutorial that

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-14 Thread Manu
I'm encouraged to see that every person in this thread so far seems to feel the same way as me regarding the syntax. On 14 March 2012 05:25, Derek Parnell ddparn...@bigpond.com wrote: On Wed, 14 Mar 2012 13:33:18 +1100, Kevin Cox kevincox...@gmail.com wrote: (int i,,float f) =

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-14 Thread RivenTheMage
On Wednesday, 14 March 2012 at 02:33:29 UTC, Kevin Cox wrote: Kind of unrelated but I think that it is important to have a way to ignore values also. Leaving them bank would sufice. (int i,,float f) = intBoringFloat(); or (int i, null, float f) = intBoringFloat(); or (int i, void, float

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-14 Thread Robert Jacques
On Wed, 14 Mar 2012 03:52:55 -0500, Manu turkey...@gmail.com wrote: I'm encouraged to see that every person in this thread so far seems to feel the same way as me regarding the syntax. On 14 March 2012 05:25, Derek Parnell ddparn...@bigpond.com wrote: On Wed, 14 Mar 2012 13:33:18 +1100,

Re: Multiple return values...

2012-03-14 Thread Ary Manzana
On 3/13/12 6:12 PM, Andrei Alexandrescu wrote: On 3/13/12 2:57 PM, Manu wrote: And you think that's more readable and intuitive than: (v1, v2, v3) = fun(); ? Yes (e.g. when I see the commas my mind starts running in all directions because that's valid code nowadays that ignores v1 and v2 and

Re: Multiple return values...

2012-03-14 Thread Andrei Alexandrescu
On 3/14/12 2:02 PM, Ary Manzana wrote: On 3/13/12 6:12 PM, Andrei Alexandrescu wrote: On 3/13/12 2:57 PM, Manu wrote: And you think that's more readable and intuitive than: (v1, v2, v3) = fun(); ? Yes (e.g. when I see the commas my mind starts running in all directions because that's valid

Re: Multiple return values...

2012-03-14 Thread Simen Kjærås
On Wed, 14 Mar 2012 20:02:50 +0100, Ary Manzana a...@esperanto.org.ar wrote: Here's what you can do in Ruby: a = 1 b = 2 # Swap the contents a, b = b, a Can you do something like that with templates in D, with a nice syntax? template to(T...) { alias T to; } auto from(T...)(T t) {

Re: Multiple return values...

2012-03-14 Thread Ary Manzana
On 3/14/12 5:00 PM, Simen Kjærås wrote: On Wed, 14 Mar 2012 20:02:50 +0100, Ary Manzana a...@esperanto.org.ar wrote: Here's what you can do in Ruby: a = 1 b = 2 # Swap the contents a, b = b, a Can you do something like that with templates in D, with a nice syntax? template to(T...) {

Re: Multiple return values...

2012-03-14 Thread Manu
On 14 March 2012 22:10, Ary Manzana a...@esperanto.org.ar wrote: On 3/14/12 5:00 PM, Simen Kjærås wrote: On Wed, 14 Mar 2012 20:02:50 +0100, Ary Manzana a...@esperanto.org.ar wrote: Here's what you can do in Ruby: a = 1 b = 2 # Swap the contents a, b = b, a Can you do something

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-14 Thread Manu
On 14 March 2012 15:17, Robert Jacques sandf...@jhu.edu wrote: But there's a reason we use /// instead of ⫻; we shouldn't require custom keyboard mappings in order to program efficiently in D. Hold that thought, I think you're missing a major franchising opportunity right there... D branded

Re: Multiple return values...

2012-03-14 Thread Andrei Alexandrescu
On 3/14/12 3:00 PM, Simen Kjærås wrote: template to(T...) { alias T to; } auto from(T...)(T t) { struct Result { T t; alias t this; } return Result( t ); } void main( ) { int a = 3; int b = 4; to!(a, b) = from(b, a); assert( a == 4 ); assert( b == 3 ); } I got reborn inside a little when

Re: Multiple return values...

2012-03-14 Thread Derek Parnell
On Thu, 15 Mar 2012 08:52:26 +1100, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/14/12 3:00 PM, Simen Kjærås wrote: template to(T...) { alias T to; } auto from(T...)(T t) { struct Result { T t; alias t this; } return Result( t ); } void main( ) { int a = 3; int b = 4;

Re: Multiple return values...

2012-03-14 Thread Simen Kjærås
On Wed, 14 Mar 2012 22:52:26 +0100, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/14/12 3:00 PM, Simen Kjærås wrote: template to(T...) { alias T to; } auto from(T...)(T t) { struct Result { T t; alias t this; } return Result( t ); } void main( ) { int a = 3; int b = 4;

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-14 Thread foobar
On Wednesday, 14 March 2012 at 13:17:47 UTC, Robert Jacques wrote: snip But there's a reason we use /// instead of ⫻; we shouldn't require custom keyboard mappings in order to program efficiently in D. Aren't we supposed to be moving towards more natural interfaces in computing? I'm sure

Re: Multiple return values...

2012-03-13 Thread Manu
On 13 March 2012 06:45, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: You see, at this point I have no idea what to believe anymore. You argued very strongly from the position of one whose life depends on efficiency. Here and there you'd mix some remark about syntax, and I'd like

Re: Multiple return values...

2012-03-13 Thread Iain Buclaw
On 13 March 2012 09:12, Manu turkey...@gmail.com wrote: On 13 March 2012 06:45, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: You see, at this point I have no idea what to believe anymore. You argued very strongly from the position of one whose life depends on efficiency. Here and

Re: Multiple return values...

2012-03-13 Thread Manu
On 13 March 2012 13:27, Iain Buclaw ibuc...@ubuntu.com wrote: What about alternative optimisations for MRV, rather than stating that it should always be returned in registers where possible (and breaking ABI on all target platforms). What about, for example, using named return value

Re: Multiple return values...

2012-03-13 Thread Andrei Alexandrescu
On 3/13/12 4:12 AM, Manu wrote: I think I feel a sense of urgency towards the ABI aspect because it is a breaking change, and I suspect the longer anything like that is left, the less likely/more risky it becomes. If it gets delayed for 6-12 months, are you honestly more or less likely to say

Re: Multiple return values...

2012-03-13 Thread Manu
On 13 March 2012 16:44, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: I thought more about it and we should be fine with two functions (untested): enum Skip {}; @property ref Skip skip() { static __gshared Skip result; return result; } void scatter(T, U...)(auto ref T

Re: Multiple return values...

2012-03-13 Thread Andrei Alexandrescu
On 3/13/12 10:48 AM, Manu wrote: float t; ... (myStruct.pos, t, _, int err) = intersectThings(); I actually find the scatter syntax better than this. Anyway, I hope you'll agree there's not much difference pragmatically. Andrei

Re: Multiple return values...

2012-03-13 Thread Manu
On 13 March 2012 18:07, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/13/12 10:48 AM, Manu wrote: float t; ... (myStruct.pos, t, _, int err) = intersectThings(); I actually find the scatter syntax better than this. Anyway, I hope you'll agree there's not much difference

Re: Multiple return values...

2012-03-13 Thread Andrei Alexandrescu
On 3/13/12 12:02 PM, Manu wrote: There's a few finicky differences. I'm still of the understanding (and I may be wrong, still mystified by some of D's more complicated template syntax) that once you give the returned tuple a name, it is structurally bound to the stack. At that point, passing any

Re: Multiple return values...

2012-03-13 Thread Manu
On 13 March 2012 19:25, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/13/12 12:02 PM, Manu wrote: There's a few finicky differences. I'm still of the understanding (and I may be wrong, still mystified by some of D's more complicated template syntax) that once you give the

Re: Multiple return values...

2012-03-13 Thread Jose Armando Garcia
On Tue, Mar 13, 2012 at 9:07 AM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/13/12 10:48 AM, Manu wrote: float t; ... (myStruct.pos, t, _, int err) = intersectThings(); This can be checked at compile time. The D compiler can check that the number of arguments and the types

Re: Multiple return values...

2012-03-13 Thread Andrei Alexandrescu
On 3/13/12 2:07 PM, Jose Armando Garcia wrote: On Tue, Mar 13, 2012 at 9:07 AM, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 3/13/12 10:48 AM, Manu wrote: float t; ... (myStruct.pos, t, _, int err) = intersectThings(); This can be checked at compile time. The D compiler

Re: Multiple return values...

2012-03-13 Thread Andrei Alexandrescu
On 3/13/12 1:20 PM, Manu wrote: What value does it add over Kenji's change? Is this because Kenji's change is unable to perform direct to existing variables? Yes. My understanding from early in the thread was that Kenji's change hides the returned tuple, and performs a convenient unpack. How

Re: Multiple return values...

2012-03-13 Thread Manu
On 13 March 2012 21:40, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/13/12 1:20 PM, Manu wrote: What value does it add over Kenji's change? Is this because Kenji's change is unable to perform direct to existing variables? Yes. My understanding from early in the thread

Re: Multiple return values...

2012-03-13 Thread Andrei Alexandrescu
On 3/13/12 2:57 PM, Manu wrote: And you think that's more readable and intuitive than: (v1, v2, v3) = fun(); ? Yes (e.g. when I see the commas my mind starts running in all directions because that's valid code nowadays that ignores v1 and v2 and keeps v3 as an lvalue). Let me put it

Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-13 Thread bearophile
Andrei Alexandrescu: Let me put it another way: I don't see one syntax over another a deal maker or deal breaker. At all. I am usually able to follow threads, but this time I am a bit lost (this discussion has mixed very different topics like ABIs, implementation efficiency of tuples and

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-13 Thread Michael
Maybe [x, y] = func(); ?

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-13 Thread foobar
On Tuesday, 13 March 2012 at 22:26:14 UTC, bearophile wrote: Andrei Alexandrescu: Let me put it another way: I don't see one syntax over another a deal maker or deal breaker. At all. I am usually able to follow threads, but this time I am a bit lost (this discussion has mixed very different

Re: Multiple return values...

2012-03-13 Thread Martin Nowak
Shall we discuss the shortcomings of his implementation? Can someone demonstrate the details of his implementation? From the little examples up in the thread, it looked like you could only declare new variables inline, but not assign out to existing ones. I'd say this needs to be added too, and

Re: Tuple unpacking syntax [Was: Re: Multiple return values...]

2012-03-13 Thread Derek Parnell
On Wed, 14 Mar 2012 13:33:18 +1100, Kevin Cox kevincox...@gmail.com wrote: Kind of unrelated but I think that it is important to have a way to ignore values also. Leaving them bank would sufice. (int i,,float f) = intBoringFloat(); For what its worth, the Euphoria Programming Language

Re: Multiple return values...

2012-03-12 Thread Timon Gehr
On 03/12/2012 05:01 AM, Robert Jacques wrote: On Sun, 11 Mar 2012 21:49:52 -0500, Mantis mail.mantis...@gmail.com wrote: 12.03.2012 4:00, Robert Jacques пишет: On Sun, 11 Mar 2012 18:15:31 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 03/11/2012 11:58 PM, Robert Jacques wrote: Manu was

Re: Multiple return values...

2012-03-12 Thread Manu
On 12 March 2012 04:44, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/11/12 6:30 PM, Manu wrote: D should define an MRV ABI which is precisely the ABI for passing multiple args TO a function, but in reverse, for any given architecture. This also has the lovely side effect of

Re: Multiple return values...

2012-03-12 Thread Manu
On 12 March 2012 04:00, Robert Jacques sandf...@jhu.edu wrote: On Sun, 11 Mar 2012 18:15:31 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 03/11/2012 11:58 PM, Robert Jacques wrote: Manu was arguing that MRV were somehow special and had mystical optimization potential. That's simply not

Re: Multiple return values...

2012-03-12 Thread Mantis
12.03.2012 6:01, Robert Jacques пишет: On Sun, 11 Mar 2012 21:49:52 -0500, Mantis mail.mantis...@gmail.com wrote: [...] That's the point of discussion. Fields of structure may not be optimized away, because they are not independent variables. In D you have unchecked pointer-to-pointer casts,

Re: Multiple return values...

2012-03-12 Thread RivenTheMage
So, function with MRV is basically the function that returns Tuple where one can specify return convention? --- auto fun() { return(Windows) tuple(1, 2.0f); } (int x, float y) = fun(); ---

Re: Multiple return values...

2012-03-12 Thread Iain Buclaw
On 12 March 2012 01:37, Andrew Wiley wiley.andre...@gmail.com wrote: On Sun, Mar 11, 2012 at 7:44 PM, Manu turkey...@gmail.com wrote: On 12 March 2012 00:58, Robert Jacques sandf...@jhu.edu wrote: That's an argument for using the right register for the job. And we can / will be doing this on

Re: Multiple return values...

2012-03-12 Thread Iain Buclaw
On 12 March 2012 00:44, Manu turkey...@gmail.com wrote: On 12 March 2012 00:58, Robert Jacques sandf...@jhu.edu wrote: That's an argument for using the right register for the job. And we can / will be doing this on x86-64, as other compilers have already done. Manu was arguing that MRV were

Re: Multiple return values...

2012-03-12 Thread Manu
On 12 March 2012 19:03, Iain Buclaw ibuc...@ubuntu.com wrote: On 12 March 2012 00:44, Manu turkey...@gmail.com wrote: On 12 March 2012 00:58, Robert Jacques sandf...@jhu.edu wrote: That's an argument for using the right register for the job. And we can / will be doing this on x86-64, as

Re: Multiple return values...

2012-03-12 Thread Iain Buclaw
On 12 March 2012 17:22, Manu turkey...@gmail.com wrote: On 12 March 2012 19:03, Iain Buclaw ibuc...@ubuntu.com wrote: On 12 March 2012 00:44, Manu turkey...@gmail.com wrote: On 12 March 2012 00:58, Robert Jacques sandf...@jhu.edu wrote: That's an argument for using the right register for

Re: Multiple return values...

2012-03-12 Thread Iain Buclaw
On 12 March 2012 17:49, Iain Buclaw ibuc...@ubuntu.com wrote: On 12 March 2012 17:22, Manu turkey...@gmail.com wrote: On 12 March 2012 19:03, Iain Buclaw ibuc...@ubuntu.com wrote: On 12 March 2012 00:44, Manu turkey...@gmail.com wrote: On 12 March 2012 00:58, Robert Jacques sandf...@jhu.edu

Re: Multiple return values...

2012-03-12 Thread Manu
On 12 March 2012 19:49, Iain Buclaw ibuc...@ubuntu.com wrote: OK, -msse2 is not an ARM target option. :~) Oh sorry, I thought you were asking about the x86 codegen ;) I used -S -O2 -float-abi=hard Looking around, the Procedure Call Standard for the ARM Architecture specifically says

Re: Multiple return values...

2012-03-12 Thread Iain Buclaw
On 12 March 2012 17:59, Manu turkey...@gmail.com wrote: On 12 March 2012 19:49, Iain Buclaw ibuc...@ubuntu.com wrote: OK, -msse2 is not an ARM target option. :~) Oh sorry, I thought you were asking about the x86 codegen ;) I used -S -O2 -float-abi=hard Looking around, the Procedure Call

Re: Multiple return values...

2012-03-12 Thread Robert Jacques
On Mon, 12 Mar 2012 02:15:55 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 03/12/2012 05:01 AM, Robert Jacques wrote: On Sun, 11 Mar 2012 21:49:52 -0500, Mantis mail.mantis...@gmail.com wrote: 12.03.2012 4:00, Robert Jacques пишет: On Sun, 11 Mar 2012 18:15:31 -0500, Timon Gehr

Re: Multiple return values...

2012-03-12 Thread Robert Jacques
On Mon, 12 Mar 2012 04:46:45 -0500, Mantis mail.mantis...@gmail.com wrote: 12.03.2012 6:01, Robert Jacques пишет: On Sun, 11 Mar 2012 21:49:52 -0500, Mantis mail.mantis...@gmail.com wrote: [...] That's the point of discussion. Fields of structure may not be optimized away, because they are not

Re: Multiple return values...

2012-03-12 Thread Robert Jacques
On Mon, 12 Mar 2012 04:25:54 -0500, Manu turkey...@gmail.com wrote: On 12 March 2012 04:00, Robert Jacques sandf...@jhu.edu wrote: On Sun, 11 Mar 2012 18:15:31 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 03/11/2012 11:58 PM, Robert Jacques wrote: Manu was arguing that MRV were somehow

Re: Multiple return values...

2012-03-12 Thread Martin Nowak
Is this basically like saying it'll never happen? There is already a pending pull request implementing the syntax, that addresses half of the feature straight up.. codegen can come later, I agreed earlier that it is of lesser importance. You don't see the immediate value in a convenient MRV

Re: Multiple return values...

2012-03-12 Thread Andrei Alexandrescu
On 3/12/12 3:37 AM, Manu wrote: On 12 March 2012 04:44, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote: On 3/11/12 6:30 PM, Manu wrote: D should define an MRV ABI which is precisely the ABI for passing multiple args

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 03:45, Robert Jacques sandf...@jhu.edu wrote: On Sat, 10 Mar 2012 19:27:05 -0600, Manu turkey...@gmail.com wrote: On 11 March 2012 00:25, Sean Cavanaugh worksonmymach...@gmail.com wrote: On 3/10/2012 4:37 AM, Manu wrote: If I pass a structure TO a function by value, I

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 04:35, Sean Cavanaugh worksonmymach...@gmail.com wrote: On 3/10/2012 8:08 PM, Mantis wrote: Tuple!(float, float) callee() { do something to achieve result in st0,st1 fst st0, st1 into stack load stack values into EAX, EDX ret } void caller() { call callee() push EAX,

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 05:04, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: On 3/10/12 4:37 AM, Manu wrote: I still fundamentally see a clear divide between a Tuple, which is a deliberately structured association of multiple values, and 'multiple return values' which is an explicit

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 05:04, Andrei Alexandrescu seewebsiteforem...@erdani.orgwrote: This analogy is tenuous for D because functions are defined to return one type, e.g. typeof(fun(args)) is defined. Once we get into disallowing that for certain functions, we're looking at major language changes

Re: Multiple return values...

2012-03-11 Thread Timon Gehr
On 03/11/2012 01:30 PM, Manu wrote: On 11 March 2012 05:04, Andrei Alexandrescu seewebsiteforem...@erdani.org mailto:seewebsiteforem...@erdani.org wrote: This analogy is tenuous for D because functions are defined to return one type, e.g. typeof(fun(args)) is defined. Once we get into

Re: Multiple return values...

2012-03-11 Thread Timon Gehr
On 03/11/2012 12:50 PM, Manu wrote: Nobody has acknowledged or disputed the majority of my points :/ I agree with the majority of your points.

Re: Multiple return values...

2012-03-11 Thread David Nadlinger
On Sunday, 11 March 2012 at 03:04:38 UTC, Andrei Alexandrescu wrote: This analogy is tenuous for D because functions are defined to return one type, e.g. typeof(fun(args)) is defined. Once we get into disallowing that for certain functions, we're looking at major language changes for little

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 14:56, Timon Gehr timon.g...@gmx.ch wrote: On 03/11/2012 12:50 PM, Manu wrote: Nobody has acknowledged or disputed the majority of my points :/ I agree with the majority of your points. Cool, well that's encouraging :) I can't really argue the implementation details, all

Re: Multiple return values...

2012-03-11 Thread Timon Gehr
On 03/11/2012 02:23 PM, Manu wrote: On 11 March 2012 14:56, Timon Gehr timon.g...@gmx.ch mailto:timon.g...@gmx.ch wrote: On 03/11/2012 12:50 PM, Manu wrote: Nobody has acknowledged or disputed the majority of my points :/ I agree with the majority of your points.

Re: Multiple return values...

2012-03-11 Thread Artur Skawina
On 03/11/12 02:27, Manu wrote: I've never seen the compiler do wildly unexpected things unless whole program optimisation is enabled The compiler can only ignore the ABI when it knows it sees the whole picture, ie whole program, or whole unit in case of private/local functions. which I don't

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 15:35, Timon Gehr timon.g...@gmx.ch wrote: On 03/11/2012 02:23 PM, Manu wrote: On 11 March 2012 14:56, Timon Gehr timon.g...@gmx.ch mailto:timon.g...@gmx.ch wrote: On 03/11/2012 12:50 PM, Manu wrote: Nobody has acknowledged or disputed the majority of

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 16:01, Artur Skawina art.08...@gmail.com wrote: which I don't imagine D will be able to support any time real soon? In fact, until GDC learns cross-module inlining, using these modes is the only way to make the compiler generate sane code Yeah I'm very concerned by this

Re: Multiple return values...

2012-03-11 Thread Artur Skawina
On 03/11/12 15:59, Manu wrote: On 11 March 2012 16:01, Artur Skawina art.08...@gmail.com mailto:art.08...@gmail.com wrote: which I don't imagine D will be able to support any time real soon? In fact, until GDC learns cross-module inlining, using these modes is the only way

Re: Multiple return values...

2012-03-11 Thread Robert Jacques
On Sun, 11 Mar 2012 05:57:05 -0500, Manu turkey...@gmail.com wrote: On 11 March 2012 04:35, Sean Cavanaugh worksonmymach...@gmail.com wrote: On 3/10/2012 8:08 PM, Mantis wrote: Tuple!(float, float) callee() { do something to achieve result in st0,st1 fst st0, st1 into stack load stack

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 18:50, Robert Jacques sandf...@jhu.edu wrote: On Sun, 11 Mar 2012 05:57:05 -0500, Manu turkey...@gmail.com wrote: On 11 March 2012 04:35, Sean Cavanaugh worksonmymach...@gmail.com wrote: On 3/10/2012 8:08 PM, Mantis wrote: Tuple!(float, float) callee() { do something

Re: Multiple return values...

2012-03-11 Thread Manu
On 11 March 2012 18:45, Artur Skawina art.08...@gmail.com wrote: Other than that, there is devirtualization - D does not have 'virtual'; the compiler can still do it and even inline the virtual methods, but it needs to know that nothing overrides the functions - impossible w/o WPO for public

Re: Multiple return values...

2012-03-11 Thread Andrei Alexandrescu
On 3/11/12 7:52 AM, Timon Gehr wrote: It is extremely obvious how multiple return values should work. (int, int) fun(); writeln(fun()); auto a = fun(); writeln(a); What should happen? Andrei

  1   2   3   >