digitalmars.D.learn - inout based on this reference?
- Simen kjaeraas (11/11) Aug 29 2010 Is it possible to make a function return dependent upon the constancy of...
- Steven Schveighoffer (5/14) Aug 30 2010 Yes. That is the bread-and-butter usage for inout.
- Steven Schveighoffer (6/21) Aug 30 2010 I should point out, the function sig should be:
- Simen kjaeraas (20/35) Aug 30 2010 So horribly broken that example does not work at all, or is that just me...
- Steven Schveighoffer (7/43) Aug 30 2010 Yes, horribly broken means does not work in almost all cases :) You
Is it possible to make a function return dependent upon the constancy of the this reference? i.e. this: struct foo { int n; inout( ref int ) getn( ) inout { return n; } } -- Simen
Aug 29 2010
On Sun, 29 Aug 2010 17:36:24 -0400, Simen kjaeraas <simen.kjaras gmail.com> wrote:Is it possible to make a function return dependent upon the constancy of the this reference? i.e. this: struct foo { int n; inout( ref int ) getn( ) inout { return n; } }Yes. That is the bread-and-butter usage for inout. Although inout is currently horribly broken. -Steve
Aug 30 2010
On Mon, 30 Aug 2010 09:08:11 -0400, Steven Schveighoffer <schveiguy yahoo.com> wrote:On Sun, 29 Aug 2010 17:36:24 -0400, Simen kjaeraas <simen.kjaras gmail.com> wrote:I should point out, the function sig should be: ref inout(int) getn() inout inout is a type modifier, ref is a storage class. -SteveIs it possible to make a function return dependent upon the constancy of the this reference? i.e. this: struct foo { int n; inout( ref int ) getn( ) inout { return n; } }Yes. That is the bread-and-butter usage for inout. Although inout is currently horribly broken.
Aug 30 2010
Steven Schveighoffer <schveiguy yahoo.com> wrote: 0123456789012345678901234567890123456789012345678901234567890123456789012On Sun, 29 Aug 2010 17:36:24 -0400, Simen kjaeraas <simen.kjaras gmail.com> wrote:So horribly broken that example does not work at all, or is that just me? This is my code, verbatim: ////////////////////////// module foo; struct bar { int n; ref inout( int ) getN( ) inout { return n; } } void main( ) { } ////////////////////////// And it gives this message: foo.d(5): Error: inout on return means inout must be on a parameter as well for inout inout(int)() -- SimenIs it possible to make a function return dependent upon the constancy of the this reference? i.e. this: struct foo { int n; inout( ref int ) getn( ) inout { return n; } }Yes. That is the bread-and-butter usage for inout. Although inout is currently horribly broken.
Aug 30 2010
On Mon, 30 Aug 2010 13:49:20 -0400, Simen kjaeraas <simen.kjaras gmail.com> wrote:Steven Schveighoffer <schveiguy yahoo.com> wrote: 0123456789012345678901234567890123456789012345678901234567890123456789012Yes, horribly broken means does not work in almost all cases :) You should defer using inout until it is fixed. As of now, it's unusable (Walter is aware and has it on his TODO list). Please vote for bug http://d.puremagic.com/issues/show_bug.cgi?id=3748 -SteveOn Sun, 29 Aug 2010 17:36:24 -0400, Simen kjaeraas <simen.kjaras gmail.com> wrote:So horribly broken that example does not work at all, or is that just me? This is my code, verbatim: ////////////////////////// module foo; struct bar { int n; ref inout( int ) getN( ) inout { return n; } } void main( ) { } ////////////////////////// And it gives this message: foo.d(5): Error: inout on return means inout must be on a parameter as well for inout inout(int)()Is it possible to make a function return dependent upon the constancy of the this reference? i.e. this: struct foo { int n; inout( ref int ) getn( ) inout { return n; } }Yes. That is the bread-and-butter usage for inout. Although inout is currently horribly broken.
Aug 30 2010