important proposal: scope keyword for class members

2009-03-06 Thread John Simon
I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside the container. Instead of a default initializer of 'null', it will initialize with t

Re: important proposal: scope keyword for class members

2009-03-06 Thread dsimcha
== Quote from John Simon (zildjoh...@gmail.com)'s article > I'd like to propose a new use for the 'scope' keyword within an aggregate > body. > Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside the container. Instead

Re: important proposal: scope keyword for class members

2009-03-07 Thread Christopher Wright
dsimcha wrote: But the whole point of classes is that they're supposed to be polymorphic. If you don't need polymorphism, that's what structs are for. You can store them either inline (default) or in separate heap space (using pointers). If you do need polymorphism, you don't know at compile

Re: important proposal: scope keyword for class members

2009-03-07 Thread John Simon
Christopher Wright Wrote: > dsimcha wrote: > > But the whole point of classes is that they're supposed to be polymorphic. > > If you > > don't need polymorphism, that's what structs are for. You can store them > > either > > inline (default) or in separate heap space (using pointers). If you

Re: important proposal: scope keyword for class members

2009-03-07 Thread Sean Kelly
John Simon wrote: I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside the container. Instead of a default initializer of 'null', it wi

Re: important proposal: scope keyword for class members

2009-03-07 Thread Sean Kelly
Sean Kelly wrote: John Simon wrote: I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside the container. Instead of a default initiali

Re: important proposal: scope keyword for class members

2009-03-07 Thread Andrei Alexandrescu
Sean Kelly wrote: John Simon wrote: I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside the container. Instead of a default initiali

Re: important proposal: scope keyword for class members

2009-03-07 Thread Sean Kelly
Andrei Alexandrescu wrote: Sean Kelly wrote: John Simon wrote: I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside the container. I

Re: important proposal: scope keyword for class members

2009-03-07 Thread Christopher Wright
John Simon wrote: You can always upcast and downcast safely, since it isn't actually a 'value' type, only the address is passed around. The type of the class remains intact. Right, but a scope variable has its type decided at compile time, always. In that way, it's not polymorphic.

Re: important proposal: scope keyword for class members

2009-03-07 Thread Christopher Wright
Sean Kelly wrote: Andrei Alexandrescu wrote: Sean Kelly wrote: John Simon wrote: I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside

Re: important proposal: scope keyword for class members

2009-03-07 Thread John Simon
Christopher Wright Wrote: > John Simon wrote: > > You can always upcast and downcast safely, since it isn't actually a > > 'value' type, only the address is passed around. The type of the class > > remains intact. > > Right, but a scope variable has its type decided at compile time, > always.

Re: important proposal: scope keyword for class members

2009-03-07 Thread John Simon
Sean Kelly Wrote: > Sean Kelly wrote: > > John Simon wrote: > >> I'd like to propose a new use for the 'scope' keyword within an > >> aggregate body. > >> > >> Members of class type declared with the scope keyword are allocated > >> not as references or pointers, but initialized directly inside

Re: important proposal: scope keyword for class members

2009-03-07 Thread Sean Kelly
John Simon wrote: Sean Kelly Wrote: Oh, I should mention that I'm not sure how the compiler would handle this scenario: class A { byte[16]; } class B { byte[32]; } class C { this( bool b ) { if( b ) o = new A; elseo = new B; } scope Object o; } If I had

Re: important proposal: scope keyword for class members

2009-03-08 Thread Sean Kelly
Christopher Wright wrote: Sean Kelly wrote: Andrei Alexandrescu wrote: Sean Kelly wrote: John Simon wrote: I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but

Re: important proposal: scope keyword for class members

2009-03-08 Thread John Simon
Sean Kelly Wrote: > John Simon wrote: > > Sean Kelly Wrote: > >> > >> Oh, I should mention that I'm not sure how the compiler would handle > >> this scenario: > >> > >> class A { byte[16]; } > >> class B { byte[32]; } > >> class C { > >> this( bool b ) { > >> if( b ) o = new A; > >>

Re: important proposal: scope keyword for class members

2009-03-08 Thread Sean Kelly
John Simon wrote: Sean Kelly Wrote: John Simon wrote: Sean Kelly Wrote: Oh, I should mention that I'm not sure how the compiler would handle this scenario: class A { byte[16]; } class B { byte[32]; } class C { this( bool b ) { if( b ) o = new A; elseo = new B;

Re: important proposal: scope keyword for class members

2009-03-08 Thread Bill Baxter
On Mon, Mar 9, 2009 at 7:12 AM, John Simon wrote: > Sean Kelly Wrote: > >> John Simon wrote: >> > Sean Kelly Wrote: >> >> >> >> Oh, I should mention that I'm not sure how the compiler would handle >> >> this scenario: >> >> >> >> class A { byte[16]; } >> >> class B { byte[32]; } >> >> class C { >>

Re: important proposal: scope keyword for class members

2009-03-08 Thread Andrei Alexandrescu
Bill Baxter wrote: On Mon, Mar 9, 2009 at 7:12 AM, John Simon wrote: Sean Kelly Wrote: John Simon wrote: Sean Kelly Wrote: Oh, I should mention that I'm not sure how the compiler would handle this scenario: class A { byte[16]; } class B { byte[32]; } class C { this( bool b ) {

Re: important proposal: scope keyword for class members

2009-03-08 Thread Sergey Gromov
Sun, 08 Mar 2009 16:06:56 -0700, Andrei Alexandrescu wrote: > Bill Baxter wrote: >> On Mon, Mar 9, 2009 at 7:12 AM, John Simon wrote: >>> Sean Kelly Wrote: >>> John Simon wrote: > Sean Kelly Wrote: >> Oh, I should mention that I'm not sure how the compiler would handle >> this sc

Re: important proposal: scope keyword for class members

2009-03-08 Thread Yigal Chripun
On 09/03/2009 00:12, John Simon wrote: Sean Kelly Wrote: John Simon wrote: Sean Kelly Wrote: Oh, I should mention that I'm not sure how the compiler would handle this scenario: class A { byte[16]; } class B { byte[32]; } class C { this( bool b ) { if( b ) o = new A; elseo = new B; } scop

Re: important proposal: scope keyword for class members

2009-03-08 Thread Denis Koroskin
On Sat, 07 Mar 2009 08:15:59 +0300, John Simon wrote: I'd like to propose a new use for the 'scope' keyword within an aggregate body. Members of class type declared with the scope keyword are allocated not as references or pointers, but initialized directly inside the container. Instead

Re: important proposal: scope keyword for class members

2009-03-09 Thread John Simon
Yigal Chripun Wrote: > On 09/03/2009 00:12, John Simon wrote: > > Sean Kelly Wrote: > > > >> John Simon wrote: > >>> Sean Kelly Wrote: > Oh, I should mention that I'm not sure how the compiler would > handle this scenario: > > class A { byte[16]; } class B { byte[32]; } class C

Re: important proposal: scope keyword for class members

2009-03-09 Thread John Simon
Denis Koroskin Wrote: > On Sat, 07 Mar 2009 08:15:59 +0300, John Simon wrote: > > > I'd like to propose a new use for the 'scope' keyword within an > > aggregate body. > > > > Members of class type declared with the scope keyword are allocated not > > as references or pointers, but initializ

Re: important proposal: scope keyword for class members

2009-03-09 Thread Sean Kelly
John Simon wrote: Oh man I've tried, believe me. I couldn't figure out how to call the destructors in-place. Also, structs can't have parameter-less constructors Have you tried just calling delete on the reference? That should do what you want. In D2 it certainly will at any rate... I have

Re: important proposal: scope keyword for class members

2009-03-11 Thread John Simon
Sean Kelly Wrote: > John Simon wrote: > > > > Oh man I've tried, believe me. > > I couldn't figure out how to call the destructors in-place. Also, structs > > can't have parameter-less constructors > > Have you tried just calling delete on the reference? That should do > what you want. In D2