Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 03, 2004 Bug 0.86 | ||||
---|---|---|---|---|
| ||||
the following does not see obj2 as a valid identifier until after this line where it is declared. --------------- bugtest2.d ----------------------- class MyObj {} int main( char[][] args ) { MyObj obj; obj = new typeof(obj); MyObj obj2 = new typeof(obj2); return 0; } // // bugtest2.d(7): undefined identifier obj2 // |
May 03, 2004 Re: Bug 0.86 | ||||
---|---|---|---|---|
| ||||
Posted in reply to one_mad_alien | That's correct, a variable is not recognized until after it is initialized. -Walter <one_mad_alien@hotmail.com> wrote in message news:c76jg8$o3q$1@digitaldaemon.com... > the following does not see obj2 as a valid identifier until after this line > where it is declared. > > --------------- bugtest2.d ----------------------- > > class MyObj {} > > int main( char[][] args ) { > MyObj obj; > obj = new typeof(obj); > MyObj obj2 = new typeof(obj2); > return 0; > } > > // > // bugtest2.d(7): undefined identifier obj2 > // > > > |
May 04, 2004 Re: Bug 0.86 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> That's correct, a variable is not recognized until after it is
> initialized. -Walter
>
>>MyObj obj2 = new typeof(obj2);
It would be nice to be able to do that... (so as not to have to duplicate the name, makes renaming classes or changing classes much easier...) but far from necccessary. And it would probably only serve to complicate the compiler if it were done...
-[Unknown]
|
May 04, 2004 Re: Bug 0.86 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | Unknown W. Brackets wrote: > Walter wrote: > >> That's correct, a variable is not recognized until after it is >> initialized. -Walter >> >>> MyObj obj2 = new typeof(obj2); >> > > It would be nice to be able to do that... (so as not to have to duplicate the name, makes renaming classes or changing classes much easier...) but far from necccessary. And it would probably only serve to complicate the compiler if it were done... > > -[Unknown] It would be even better if you could write short hand something like: MyObj new obj2; -- -Anderson: http://badmama.com.au/~anderson/ |
May 04, 2004 Re: Bug 0.86 | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote:
> It would be even better if you could write short hand something like:
>
> MyObj new obj2;
Hmm, I would suggest that this would be a bit more logical reading it:
new MyObj obj2;
But, then, it might get confusing when compared to:
new MyObj();
Although, that does beg the question of whether you want this...
MyObj new obj2(2, 3), obj3(4, 5);
But, really, this is all laziness, because the following isn't all that hard to type:
MyObj obj2 = new MyObj(2, 3), obj3 = new MyObj(4, 5);
-[Unknown]
|
Copyright © 1999-2021 by the D Language Foundation