Re: Error: constant false is not an lvalue

2009-08-31 Thread Manfred_Nowak
Steven Schveighoffer wrote: > In fact, it does work, in D1 no less. thx ... and another example, that initializing with int.max would serve Walter's intentions better. -manfred

Re: Error: constant false is not an lvalue

2009-08-31 Thread Steven Schveighoffer
On Mon, 31 Aug 2009 14:55:43 -0400, Steven Schveighoffer wrote: It's possible that something like what you wrote could work (although I'd write it foo(ref int i = j)). In fact, it does work, in D1 no less. # cat testme.d import tango.io.Stdout; int j; void foo(ref int i = j) { i++;

Re: Error: constant false is not an lvalue

2009-08-31 Thread Steven Schveighoffer
On Mon, 31 Aug 2009 13:00:34 -0400, Manfred_Nowak wrote: Steven Schveighoffer wrote: What is i referencing when you call: foo(); Is this an argument for making int j; void foo(ref int i = &j); foo(): legal D? No, I'm just trying to explain why having a default value for a ref

Re: Error: constant false is not an lvalue

2009-08-31 Thread Manfred_Nowak
Steven Schveighoffer wrote: > What is i referencing when you call: > foo(); Is this an argument for making int j; void foo(ref int i = &j); foo(): legal D? -manfred

Re: Error: constant false is not an lvalue

2009-08-31 Thread Steven Schveighoffer
On Sun, 30 Aug 2009 11:25:59 -0400, Ellery Newcomer wrote: Steven Schveighoffer wrote: On Sat, 29 Aug 2009 20:15:55 -0400, Ellery Newcomer wrote: void blah(out bool a = false){ // blah blah blah } compile time use of blah results in error. Am I doing anything wrong? out implies a ref

Re: Error: constant false is not an lvalue

2009-08-31 Thread Don
Rainer Deyke wrote: Jarrett Billingsley wrote: "Members are always initialized to the default initializer for their type, which is usually 0 for integer types and NAN for floating point types. This eliminates an entire class of obscure problems that come from neglecting to initialize a member i

Re: Error: constant false is not an lvalue

2009-08-30 Thread Rainer Deyke
Jarrett Billingsley wrote: > "Members are always initialized to the default initializer for their > type, which is usually 0 for integer types and NAN for floating point > types. This eliminates an entire class of obscure problems that come > from neglecting to initialize a member in one of the co

Re: Error: constant false is not an lvalue

2009-08-30 Thread Rainer Deyke
Jarrett Billingsley wrote: > On Sun, Aug 30, 2009 at 3:02 PM, Rainer Deyke wrote: >> The purpose of default initialization is not to find or reduce bugs, but >> to reduce the size of legal programs. > > I'm wondering where the heck you got that justification. By looking at the actual effect of de

Re: Error: constant false is not an lvalue

2009-08-30 Thread Jarrett Billingsley
On Sun, Aug 30, 2009 at 3:14 PM, Jarrett Billingsley wrote: > On Sun, Aug 30, 2009 at 3:02 PM, Rainer Deyke wrote: >> The purpose of default initialization is not to find or reduce bugs, but >> to reduce the size of legal programs. > > I'm wondering where the heck you got that justification. Also,

Re: Error: constant false is not an lvalue

2009-08-30 Thread Jarrett Billingsley
On Sun, Aug 30, 2009 at 3:02 PM, Rainer Deyke wrote: > The purpose of default initialization is not to find or reduce bugs, but > to reduce the size of legal programs. I'm wondering where the heck you got that justification.

Re: Error: constant false is not an lvalue

2009-08-30 Thread Rainer Deyke
Jarrett Billingsley wrote: > "It is an error to use a local variable without first assigning it a > value. The implementation may not always be able to detect these > cases. Other language compilers sometimes issue a warning for this, > but since it is always a bug, it should be an error." > http:/

Re: Error: constant false is not an lvalue

2009-08-30 Thread Ellery Newcomer
Steven Schveighoffer wrote: > On Sat, 29 Aug 2009 20:15:55 -0400, Ellery Newcomer > wrote: > >> void blah(out bool a = false){ >> // blah blah blah >> } >> >> compile time use of blah results in error. >> >> Am I doing anything wrong? > > out implies a reference. You can't have a reference to

Re: Error: constant false is not an lvalue

2009-08-30 Thread grauzone
I wouldn't be surprised if W himself has forgotten about this rule, since other parts of the spec make no mention of it, or seem to depend on the default-initialization of variables. "If the Initializer is void, however, the variable is not initialized. If its value is used before it is set, unde

Re: Error: constant false is not an lvalue

2009-08-30 Thread Jarrett Billingsley
On Sun, Aug 30, 2009 at 7:13 AM, grauzone wrote: >> Although teeechnically speaking that would be illegal code. The D >> spec says that it's not legal to use the value of uninitialized >> variables. Default initialization is kind of a poor man's substitute >> for actual flow control which deter

Re: Error: constant false is not an lvalue

2009-08-30 Thread Jarrett Billingsley
On Sun, Aug 30, 2009 at 5:34 AM, Rainer Deyke wrote: > Jarrett Billingsley wrote: >> Although teeechnically speaking that would be illegal code. The D >> spec says that it's not legal to use the value of uninitialized >> variables. Default initialization is kind of a poor man's substitute >> fo

Re: Error: constant false is not an lvalue

2009-08-30 Thread grauzone
Jarrett Billingsley wrote: On Sun, Aug 30, 2009 at 12:24 AM, Ary Borenszweig wrote: Steven Schveighoffer escribió: On Sat, 29 Aug 2009 20:15:55 -0400, Ellery Newcomer wrote: void blah(out bool a = false){ // blah blah blah } compile time use of blah results in error. Am I doing anything w

Re: Error: constant false is not an lvalue

2009-08-30 Thread Rainer Deyke
Jarrett Billingsley wrote: > Although teeechnically speaking that would be illegal code. The D > spec says that it's not legal to use the value of uninitialized > variables. Default initialization is kind of a poor man's substitute > for actual flow control which determines that. By relying on

Re: Error: constant false is not an lvalue

2009-08-29 Thread Jarrett Billingsley
On Sun, Aug 30, 2009 at 12:24 AM, Ary Borenszweig wrote: > Steven Schveighoffer escribió: >> >> On Sat, 29 Aug 2009 20:15:55 -0400, Ellery Newcomer >> wrote: >> >>> void blah(out bool a = false){ >>>  // blah blah blah >>> } >>> >>> compile time use of blah results in error. >>> >>> Am I doing any

Re: Error: constant false is not an lvalue

2009-08-29 Thread Ary Borenszweig
Steven Schveighoffer escribió: On Sat, 29 Aug 2009 20:15:55 -0400, Ellery Newcomer wrote: void blah(out bool a = false){ // blah blah blah } compile time use of blah results in error. Am I doing anything wrong? out implies a reference. You can't have a reference to a manifest constant

Re: Error: constant false is not an lvalue

2009-08-29 Thread Steven Schveighoffer
On Sat, 29 Aug 2009 20:15:55 -0400, Ellery Newcomer wrote: void blah(out bool a = false){ // blah blah blah } compile time use of blah results in error. Am I doing anything wrong? out implies a reference. You can't have a reference to a manifest constant like that. If you want to en

Error: constant false is not an lvalue

2009-08-29 Thread Ellery Newcomer
void blah(out bool a = false){ // blah blah blah } compile time use of blah results in error. Am I doing anything wrong?