Re: "ref const" parameters in functions

2012-04-02 Thread Jonathan M Davis
On Tuesday, April 03, 2012 00:28:03 Timon Gehr wrote: > On 04/02/2012 06:23 AM, Jonathan M Davis wrote: > > No. It's not. It's a temporary, and temporaries are almost always rvalues. > > The sole (and very bizarre) exception is struct literals (e.g. ABC(20) is > > currently considered an lvalue). >

Re: "ref const" parameters in functions

2012-04-02 Thread Timon Gehr
On 04/02/2012 06:23 AM, Jonathan M Davis wrote: No. It's not. It's a temporary, and temporaries are almost always rvalues. The sole (and very bizarre) exception is struct literals (e.g. ABC(20) is currently considered an lvalue). DMD 2.059head treats struct literals as rvalues.

Re: "ref const" parameters in functions

2012-04-02 Thread Steven Schveighoffer
On Mon, 02 Apr 2012 00:23:50 -0400, Jonathan M Davis wrote: No. It's not. It's a temporary, and temporaries are almost always rvalues. The sole (and very bizarre) exception is struct literals (e.g. ABC(20) is currently considered an lvalue). It results in the bizarre situation that a fun

Re: "ref const" parameters in functions

2012-04-01 Thread L-MAN
On Monday, 2 April 2012 at 05:03:48 UTC, Jonathan M Davis wrote: On Sunday, April 01, 2012 21:23:50 Jonathan M Davis wrote: On Monday, April 02, 2012 05:46:24 L-MAN wrote: Sure, if you have large structs, making a lot of copies of them can be expensive. But to avoid that, you're going to have t

Re: "ref const" parameters in functions

2012-04-01 Thread Jonathan M Davis
On Sunday, April 01, 2012 21:23:50 Jonathan M Davis wrote: > On Monday, April 02, 2012 05:46:24 L-MAN wrote: > Sure, if you have large structs, making a lot of copies of them can be > expensive. But to avoid that, you're going to have to avoid coding in a way > which creates temporaries, and expres

Re: "ref const" parameters in functions

2012-04-01 Thread Jonathan M Davis
On Monday, April 02, 2012 05:46:24 L-MAN wrote: > About temporaries in operators +-/*.. you're right, it is not a > secret. > references in other functions (not in operators) too. > > > I can't understand one thing: > ABC abc; // ABC is a struct that consists of some 4x4 matrix for > example >

Re: "ref const" parameters in functions

2012-04-01 Thread L-MAN
On Sunday, 1 April 2012 at 08:22:08 UTC, Jonathan M Davis wrote: On Sunday, April 01, 2012 09:10:58 L-MAN wrote: On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis wrote: > On Saturday, March 31, 2012 23:25:51 L-MAN wrote: >> Hello everybody! >> >> I'm trying to use some function FN

Re: "ref const" parameters in functions

2012-04-01 Thread Jonathan M Davis
On Sunday, April 01, 2012 09:10:58 L-MAN wrote: > On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis > > wrote: > > On Saturday, March 31, 2012 23:25:51 L-MAN wrote: > >> Hello everybody! > >> > >> I'm trying to use some function FN like this: > >> > >> struct X > >> { > >> > >> pro

Re: "ref const" parameters in functions

2012-04-01 Thread L-MAN
On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis wrote: On Saturday, March 31, 2012 23:25:51 L-MAN wrote: Hello everybody! I'm trying to use some function FN like this: struct X { protected double _x; // double type for example public @property double X() const { return _x; }

Re: "ref const" parameters in functions

2012-03-31 Thread L-MAN
On Saturday, 31 March 2012 at 21:42:05 UTC, Jonathan M Davis wrote: On Saturday, March 31, 2012 23:25:51 L-MAN wrote: Hello everybody! I'm trying to use some function FN like this: struct X { protected double _x; // double type for example public @property double X() const { return _x; }

Re: "ref const" parameters in functions

2012-03-31 Thread Jonathan M Davis
On Saturday, March 31, 2012 23:25:51 L-MAN wrote: > Hello everybody! > > I'm trying to use some function FN like this: > > struct X > { > protected double _x; // double type for example > public @property double X() const { return _x; } > > // ctor > public this(double x) { _x = x; } //

"ref const" parameters in functions

2012-03-31 Thread L-MAN
Hello everybody! I'm trying to use some function FN like this: struct X { protected double _x; // double type for example public @property double X() const { return _x; } // ctor public this(double x) { _x = x; } // double type for example void FN(ref const(double) in_x) // double type f