Re: Struct inheritance

2015-02-24 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 24, 2015 at 06:22:05PM +, ketmar via Digitalmars-d-learn wrote: > On Tue, 24 Feb 2015 12:05:50 +, amber wrote: > > > Hi, > > > > Is it possible in D to have inheritance using value types, i.e. > > structs? > > > > Also I don't quite understand how copy ctors work in D. Do I n

Re: Struct inheritance

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 12:05:50 +, amber wrote: > Hi, > > Is it possible in D to have inheritance using value types, i.e. structs? > > Also I don't quite understand how copy ctors work in D. Do I need to > implement opAssign(S other) {}, or this(this) {} and what's the > difference between thes

Re: Struct inheritance

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 18:19:39 +, ketmar wrote: > On Tue, 24 Feb 2015 12:05:50 +, amber wrote: > >> Hi, >> >> Is it possible in D to have inheritance using value types, i.e. >> structs? >> >> Also I don't quite understand how copy ctors work in D. Do I need to >> implement opAssign(S othe

Re: Struct inheritance

2015-02-24 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Feb 2015 12:05:50 +, amber wrote: > Hi, > > Is it possible in D to have inheritance using value types, i.e. structs? > > Also I don't quite understand how copy ctors work in D. Do I need to > implement opAssign(S other) {}, or this(this) {} and what's the > difference between thes

Re: Struct inheritance

2015-02-24 Thread amber via Digitalmars-d-learn
On Tuesday, 24 February 2015 at 12:16:43 UTC, Tobias Pankrath wrote: On Tuesday, 24 February 2015 at 12:05:51 UTC, amber wrote: Hi, Is it possible in D to have inheritance using value types, i.e. structs? No runtime polymorphism, but a kind of sub typing via alias this. struct S { void fo

Re: Struct inheritance

2015-02-24 Thread Tobias Pankrath via Digitalmars-d-learn
On Tuesday, 24 February 2015 at 12:05:51 UTC, amber wrote: Hi, Is it possible in D to have inheritance using value types, i.e. structs? No runtime polymorphism, but a kind of sub typing via alias this. struct S { void foo() { writeln("S.foo"); } struct T { S s; alias s this; } T t; t.foo();

Struct inheritance

2015-02-24 Thread amber via Digitalmars-d-learn
Hi, Is it possible in D to have inheritance using value types, i.e. structs? Also I don't quite understand how copy ctors work in D. Do I need to implement opAssign(S other) {}, or this(this) {} and what's the difference between these two? Thanks, Amber

Re: Struct "inheritance"

2012-02-05 Thread Daniel Murphy
I guess you've found a bug then. :) "Vidar Wahlberg" wrote in message news:jgm7sh$k4u$1...@digitalmars.com... > On 2012-02-05 15:19, Daniel Murphy wrote: >> The names only need to match if the compiler/build tool has to find the >> module itself. If you call the compiler with all modules listed

Re: Struct "inheritance"

2012-02-05 Thread Vidar Wahlberg
On 2012-02-05 15:19, Daniel Murphy wrote: The names only need to match if the compiler/build tool has to find the module itself. If you call the compiler with all modules listed: gdc bar.d Foo.d etc.d then it should be able to work it out. (This is how it works with dmd, anyway. GDC is probabl

Re: Struct "inheritance"

2012-02-05 Thread Daniel Murphy
"Vidar Wahlberg" wrote in message news:jgm2qk$c2g$1...@digitalmars.com... > Adding a note about GDC (4.6.2) here: > It appears like it ignores "module ;" and always use the filename > for module name (or I've misunderstood what "module" is used for). If I > create a file "Foo.d" which contains

Re: Struct "inheritance"

2012-02-05 Thread Vidar Wahlberg
On 2012-02-05 14:16, Simen Kjærås wrote: On Sun, 05 Feb 2012 11:58:40 +0100, Vidar Wahlberg wrote: Also, is this really ambiguous? Are there any cases where you can have a module name followed by a parentheses, i.e. "("? Not that I know. Possibly something that could make the language sligh

Re: Struct "inheritance"

2012-02-05 Thread Simen Kjærås
On Sun, 05 Feb 2012 11:58:40 +0100, Vidar Wahlberg wrote: Also, is this really ambiguous? Are there any cases where you can have a module name followed by a parentheses, i.e. "("? Not that I know. > I cannot seem to recreate this error message. Which version of the > compiler are you

Re: Struct "inheritance"

2012-02-05 Thread Vidar Wahlberg
Sending this again, got an error the first time and it appears like it was not sent. On 2012-02-04 21:48, Simen Kjærås wrote: > I see. There's a hint in the error message: "function expected [...], > not module". Struct is the name of a module, so the compiler thinks > you want to access somethi

Re: Struct "inheritance"

2012-02-04 Thread Ali Çehreli
On 02/04/2012 08:25 AM, Ali Çehreli wrote: The following templatizes the coordinate types, but you could use put write everywhere: That should be "... you could write *ints* everywhere". Ali

Re: Struct "inheritance"

2012-02-04 Thread Ali Çehreli
On 02/04/2012 03:38 AM, Vidar Wahlberg wrote: > Let's say I got a struct for a location on a 2-dimensional plane: > struct Point { > int x; > int y; > } > Further I also need to represent a location in a 3-dimensional space: > struct Coordinate { > int x; > int y; > int z; > } > If these were cla

Re: Struct "inheritance"

2012-02-04 Thread Vidar Wahlberg
On 2012-02-04 14:45, Simen Kjærås wrote: Like bearophile said, Point(x, y) should work - assuming you have defined no other constructors for Point. You are correct, my apologies for not testing more thoroughly. Let me try again, explaining the real issue: I have 3 files: -- Bar.d -- import Foo;

Re: Struct "inheritance"

2012-02-04 Thread Simen Kjærås
On Sat, 04 Feb 2012 13:55:55 +0100, Vidar Wahlberg wrote: On 2012-02-04 13:06, Simen Kjærås wrote: It seems that what you want is alias this: Thank you both, that's exactly what I needed. Leeching a bit more on the thread: Going back to the method: int somethingNifty(Point p) { return

Re: Struct "inheritance"

2012-02-04 Thread bearophile
Vidar Wahlberg: > Leeching a bit more on the thread: > Going back to the method: > int somethingNifty(Point p) { >return p.x + p.y; > } > > Let's say I have the following code: > for (x; 0 .. 10) { >for (y; 0 .. 10) { > Point p = {x, y}; > somethingNifty(p); >} > } > > [How

Re: Struct "inheritance"

2012-02-04 Thread Vidar Wahlberg
On 2012-02-04 13:06, Simen Kjærås wrote: It seems that what you want is alias this: Thank you both, that's exactly what I needed. Leeching a bit more on the thread: Going back to the method: int somethingNifty(Point p) { return p.x + p.y; } Let's say I have the following code: for (x; 0 ..

Re: Struct "inheritance"

2012-02-04 Thread Simen Kjærås
On Sat, 04 Feb 2012 12:38:30 +0100, Vidar Wahlberg wrote: Good day. I know "inheritance" is a misleading word as there's no such thing when it comes to structs, but I couldn't think of a better description for this problem: Let's say I got a struct for a location on a 2-dimensional pla

Struct "inheritance"

2012-02-04 Thread Vidar Wahlberg
Good day. I know "inheritance" is a misleading word as there's no such thing when it comes to structs, but I couldn't think of a better description for this problem: Let's say I got a struct for a location on a 2-dimensional plane: struct Point { int x; int y; } Further I also need to rep

Re: Struct "inheritance"

2012-02-04 Thread Trass3r
So why not just use classes? I've understood it as there may be a performance gain by using structs over classes, and in my program Point and Coordinate are used heavily. The other big difference is value vs. reference type. You can use alias this to achieve something like &q

Re: Struct "inheritance"

2012-02-04 Thread Simen Kjærås
On Sat, 04 Feb 2012 15:04:50 +0100, Vidar Wahlberg wrote: This code does not compile: Bar.d:6: Error: function expected before (), not module Struct of type void Bar.d:6: Error: constructor Foo.Foo.this (Struct s) is not callable using argument types (_error_) Why is that? I see. Ther

Re: struct inheritance need?

2008-12-25 Thread Weed
Kagamin пишет: > Weed Wrote: > >> If you do not want to initialize repeatedly matrix inside the sub, which >> often cause each other, must be static matrices or declared as global >> (in relation to these procedures). You agree with that? > > What's problem? If you want static or global variabl

Re: struct inheritance need?

2008-12-25 Thread Weed
Kagamin пишет: Weed Wrote: If you do not want to initialize repeatedly matrix inside the sub, which often cause each other, must be static matrices or declared as global (in relation to these procedures). You agree with that? What's problem? If you want static or global variables, you have t

Re: struct inheritance need?

2008-12-25 Thread Kagamin
Weed Wrote: > If you do not want to initialize repeatedly matrix inside the sub, which > often cause each other, must be static matrices or declared as global > (in relation to these procedures). You agree with that? What's problem? If you want static or global variables, you have them in D. >

Re: struct inheritance need?

2008-12-24 Thread Weed
Kagamin пишет: Weed Wrote: too cannot be initialized in a compile time. Sure it can't. Does it cause that big problems? Sometimes it is the only way to avoid a large number of global ad In D module variables can be protected by access modifiers and become module-local. Module full of mathem

Re: struct inheritance need?

2008-12-24 Thread Kagamin
Weed Wrote: > too cannot be initialized in a compile time. > >>> Sure it can't. Does it cause that big problems? > >> Sometimes it is the only way to avoid a large number of global ad > > > > In D module variables can be protected by access modifiers and become > > module-local. > > Module

Re: struct inheritance need?

2008-12-24 Thread Weed
Weed пишет: Kagamin пишет: Weed Wrote: I'd prefer run-time checks, though templates can be used for sure. This problem would help solve the availability of inheritance for structs or compile-time creation of class instances. And I see no problem. Absence of compile-time object creation does

Re: struct inheritance need?

2008-12-24 Thread Weed
Kagamin пишет: Weed Wrote: It is not necessary to suggest to wrap up "pixel" in a class - then it too cannot be initialized in a compile time. Sure it can't. Does it cause that big problems? Sometimes it is the only way to avoid a large number of global ad In D module variables can be prote

Re: struct inheritance need?

2008-12-24 Thread Kagamin
Weed Wrote: > >> It is not necessary to suggest to wrap up "pixel" in a class - then it > >> too cannot be initialized in a compile time. > > > > Sure it can't. Does it cause that big problems? > > Sometimes it is the only way to avoid a large number of global ad In D module variables can be p

Re: struct inheritance need?

2008-12-23 Thread Weed
Kagamin пишет: Weed Wrote: The problem is not in use templates. Templates are implementing some of the functionality of 2 types of structures matrices (normal and dynamic). But the structures do not inherit, then to add functionality matrix to other entities ( "pixel", "image" etc) sites wi

Re: struct inheritance need?

2008-12-23 Thread Kagamin
Weed Wrote: > The problem is not in use templates. > > Templates are implementing some of the functionality of 2 types of > structures matrices (normal and dynamic). But the structures do not > inherit, then to add functionality matrix to other entities ( "pixel", > "image" etc) sites will hav

Re: struct inheritance need?

2008-12-23 Thread Weed
Kagamin пишет: Weed Wrote: I'd prefer run-time checks, though templates can be used for sure. This problem would help solve the availability of inheritance for structs or compile-time creation of class instances. And I see no problem. Absence of compile-time object creation doesn't prevent

Re: struct inheritance need?

2008-12-23 Thread Kagamin
Weed Wrote: > > I'd prefer run-time checks, though > > templates can be used for sure. > > This problem would help solve the availability of inheritance for > structs or compile-time creation of class instances. I see no way, how it can help.

Re: struct inheritance need?

2008-12-23 Thread Kagamin
Weed Wrote: > > I'd prefer run-time checks, though > > templates can be used for sure. > > This problem would help solve the availability of inheritance for > structs or compile-time creation of class instances. And I see no problem. Absence of compile-time object creation doesn't prevent you

Re: struct inheritance need?

2008-12-22 Thread Weed
Kagamin пишет: Weed Wrote: that is, suppose that after some action should get a matrix matrix3x1 Well... if you want to template every piece of your code, this can cause disaster, so I think, this is not very good design. For example, multiplication method will be duplicated N*N*N times for a

Re: struct inheritance need?

2008-12-22 Thread Kagamin
Weed Wrote: > that is, suppose that after some action should get a matrix matrix3x1 Well... if you want to template every piece of your code, this can cause disaster, so I think, this is not very good design. For example, multiplication method will be duplicated N*N*N times for all possible mat

Re: struct inheritance need?

2008-12-22 Thread Sergey Gromov
Sun, 21 Dec 2008 12:04:42 -0500, Kagamin wrote: > Sergey Gromov Wrote: > >> C++ static object constructors execute at run time except for trivial >> cases. > > Although I think it's not guaranteed to work this way and compiler > decides when to execute constructor. So code should be ready for >

Compile-time reference type objects construction (Was - Re: struct inheritance need?)

2008-12-21 Thread Denis Koroskin
On Sun, 21 Dec 2008 19:34:52 +0300, Kagamin wrote: Derek Parnell Wrote: I think he wants to have some objects constructed at compile-time. Sure he wants. From my point of view, this technique is supposed to be a means to solve some problem rather than problem itself. But this problem wa

Re: struct inheritance need?

2008-12-21 Thread Weed
Weed пишет: Kagamin пишет: Weed Wrote: Sure he wants. From my point of view, this technique is supposed to be a means to solve some problem rather than problem itself. But this problem was not put. please read it thread: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars

Re: struct inheritance need?

2008-12-21 Thread Weed
Kagamin пишет: Weed Wrote: Sure he wants. From my point of view, this technique is supposed to be a means to solve some problem rather than problem itself. But this problem was not put. please read it thread: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id

Re: struct inheritance need?

2008-12-21 Thread Kagamin
Weed Wrote: > > Sure he wants. From my point of view, this technique is supposed to be a > > means to solve some problem rather than problem itself. But this problem > > was not put. > > please read it thread: > http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_i

Re: struct inheritance need?

2008-12-21 Thread Kagamin
Sergey Gromov Wrote: > C++ static object constructors execute at run time except for trivial > cases. Although I think it's not guaranteed to work this way and compiler decides when to execute constructor. So code should be ready for run-time evaluation. And as code evolves those constructors c

Re: struct inheritance need?

2008-12-21 Thread Weed
Kagamin пишет: Derek Parnell Wrote: I think he wants to have some objects constructed at compile-time. Sure he wants. From my point of view, this technique is supposed to be a means to solve some problem rather than problem itself. But this problem was not put. please read it thread: http:

Re: struct inheritance need?

2008-12-21 Thread Weed
Kagamin пишет: Derek Parnell Wrote: I think he wants to have some objects constructed at compile-time. Sure he wants. From my point of view, this technique is supposed to be a means to solve some problem rather than problem itself. But this problem was not put. Please read even this editi

Re: struct inheritance need?

2008-12-21 Thread Kagamin
Derek Parnell Wrote: > I think he wants to have some objects constructed at compile-time. Sure he wants. From my point of view, this technique is supposed to be a means to solve some problem rather than problem itself. But this problem was not put.

Re: struct inheritance need?

2008-12-20 Thread Christopher Wright
Denis Koroskin wrote: On Sat, 20 Dec 2008 16:46:44 +0300, Christopher Wright wrote: Sergey Gromov wrote: Thu, 18 Dec 2008 18:36:07 -0500, Christopher Wright wrote: Weed wrote: Compile-time creation an object of class or (most likely wrong) struct inheritance. I have prepared a distinct

Re: struct inheritance need?

2008-12-20 Thread Denis Koroskin
On Sat, 20 Dec 2008 16:46:44 +0300, Christopher Wright wrote: Sergey Gromov wrote: Thu, 18 Dec 2008 18:36:07 -0500, Christopher Wright wrote: Weed wrote: Compile-time creation an object of class or (most likely wrong) struct inheritance. I have prepared a distinct feature request and

Re: struct inheritance need?

2008-12-20 Thread Christopher Wright
Sergey Gromov wrote: Thu, 18 Dec 2008 18:36:07 -0500, Christopher Wright wrote: Weed wrote: Compile-time creation an object of class or (most likely wrong) struct inheritance. I have prepared a distinct feature request and send it later You aren't providing a use case, though. Why not

Re: struct inheritance need?

2008-12-19 Thread Derek Parnell
On Fri, 19 Dec 2008 04:07:40 -0500, Kagamin wrote: > Derek Parnell Wrote: > >> A static constructor (also known as the Module constructor) executes at >> program run-time and not at program compile-time. > > So do C++ static object constructors. Though C++ has syntax sugar, which > helps writin

Re: struct inheritance need?

2008-12-19 Thread Sergey Gromov
Thu, 18 Dec 2008 18:36:07 -0500, Christopher Wright wrote: > Weed wrote: >> Compile-time creation an object of class or (most likely wrong) struct >> inheritance. >> >> I have prepared a distinct feature request and send it later > > You aren't providi

Re: struct inheritance need?

2008-12-19 Thread Sergey Gromov
Fri, 19 Dec 2008 04:07:40 -0500, Kagamin wrote: > Derek Parnell Wrote: > >> A static constructor (also known as the Module constructor) executes at >> program run-time and not at program compile-time. > > So do C++ static object constructors. Though C++ has syntax sugar, > which helps writing de

Re: struct inheritance need?

2008-12-19 Thread Kagamin
Derek Parnell Wrote: > A static constructor (also known as the Module constructor) executes at > program run-time and not at program compile-time. So do C++ static object constructors. Though C++ has syntax sugar, which helps writing declaration and initialization at the same place.

Re: struct inheritance need?

2008-12-18 Thread Weed
Derek Parnell пишет: On Thu, 18 Dec 2008 07:24:34 -0500, Kagamin wrote: Static constructor can execute any valid D statements including construction of objects. A static constructor (also known as the Module constructor) executes at program run-time and not at program compile-time. I think W

Re: struct inheritance need?

2008-12-18 Thread Christopher Wright
Weed wrote: Compile-time creation an object of class or (most likely wrong) struct inheritance. I have prepared a distinct feature request and send it later You aren't providing a use case, though. Why not show an example (actual code) of what you would do if you had this ability?

Re: struct inheritance need?

2008-12-18 Thread Derek Parnell
On Thu, 18 Dec 2008 07:24:34 -0500, Kagamin wrote: > Static constructor can execute any valid D statements including construction > of objects. A static constructor (also known as the Module constructor) executes at program run-time and not at program compile-time. I think Weed wants the ability

Re: struct inheritance need?

2008-12-18 Thread Kagamin
Weed Wrote: > Therefore, it can not create instance of object. You have a trouble with terminology here. In my example m=new Matrix(7); creates an instance of Matrix class.

Re: struct inheritance need?

2008-12-18 Thread Kagamin
naryl Wrote: > Weed wants every object to be declared in the function where it is needed. Haa?.. void main() { Matrix m=new Matrix(7); writeln(m.i); }

Re: struct inheritance need?

2008-12-18 Thread naryl
Kagamin Wrote: > Static constructor can execute any valid D statements including construction > of objects. > This works: > --- > import std.stdio; > > class Matrix > { > int i; > > this(int j) > { > i=j; > } > } > > Matrix m; > > static this() > { >

Re: struct inheritance need?

2008-12-18 Thread Weed
Kagamin пишет: Weed Wrote: Kagamin пишет: Weed Wrote: Global variables are static members of module, wich is similar to class and also has static constructor. So what? So your problem is solved. If everything was so simple! :) Once again: the static constructor of class NOT constructs an

Re: struct inheritance need?

2008-12-18 Thread Kagamin
Weed Wrote: > Kagamin ÐÉÛÅÔ: > > Weed Wrote: > > > >>> Global variables are static members of module, wich is similar to > >>> class and also has static constructor. > >> So what? > > > > So your problem is solved. > > If everything was so simple! :) > > Once again: the static constructor of c

Re: struct inheritance need?

2008-12-18 Thread Weed
Weed пишет: Kagamin пишет: Weed Wrote: Global variables are static members of module, wich is similar to class and also has static constructor. So what? So your problem is solved. If everything was so simple! :) Once again: the static constructor of class NOT constructs an object. He ju

Re: struct inheritance need?

2008-12-18 Thread Weed
Kagamin пишет: Weed Wrote: Global variables are static members of module, wich is similar to class and also has static constructor. So what? So your problem is solved. If everything was so simple! :) Once again: the static constructor of class NOT constructs an object. He just fills the

Re: struct inheritance need?

2008-12-18 Thread Kagamin
Well, the wish to place an object at specific location is not a problem, it's a wish.

Re: struct inheritance need?

2008-12-18 Thread Kagamin
Weed Wrote: > > Global variables are static members of module, wich is similar to > > class and also has static constructor. > > So what? So your problem is solved.

Re: struct inheritance need?

2008-12-18 Thread Weed
Kagamin пишет: Weed Wrote: There does not need a static initialization of static members of the class. There must be able to create objects of classes at compile time. Well, these objects should be placed in some static variables, right? Yes Static variables are initialized with static co

Re: struct inheritance need?

2008-12-18 Thread Kagamin
Weed Wrote: > There does not need a static initialization of static members of the > class. There must be able to create objects of classes at compile time. Well, these objects should be placed in some static variables, right? Static variables are initialized with static constructors. Global va

Re: struct inheritance need?

2008-12-17 Thread Weed
Janderson пишет: Weed wrote: Janderson пишет: Weed wrote: I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runt

Re: struct inheritance need?

2008-12-17 Thread Janderson
Weed wrote: Janderson пишет: Weed wrote: I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runtime. I have decid

Re: struct inheritance need?

2008-12-17 Thread Weed
likely wrong) struct inheritance. I have prepared a distinct feature request and send it later You can read this in the digitalmars.D, topic: Feature request: Deploying a class instance in the default data segment

Re: struct inheritance need?

2008-12-17 Thread Weed
) struct inheritance. I have prepared a distinct feature request and send it later

Re: struct inheritance need?

2008-12-17 Thread Weed
) struct inheritance. I have prepared a distinct feature request, send it later

Re: struct inheritance need?

2008-12-17 Thread Christopher Wright
Weed wrote: If I create struct MatrixStruct for compile-time matrix and class MatrixClass for all other I will not be able to create a function of interaction between these objects through the templates because some of them will be announced before the other and it will not be able to get anot

Re: struct inheritance need?

2008-12-17 Thread Weed
Janderson пишет: Weed wrote: I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runtime. I have decided to make it s

Re: struct inheritance need?

2008-12-17 Thread Janderson
Weed wrote: I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runtime. I have decided to make it struct because I ne

Re: struct inheritance need?

2008-12-17 Thread Weed
Weed пишет: Kagamin пишет: Weed Wrote: I agree. In my case I chose to structure rather than a class because it can be initialized at compile time. But now I thing must be allowed to deploy class in the default data segment. And add the possibility of creating a object of class at compile

Re: struct inheritance need?

2008-12-17 Thread Weed
Kagamin пишет: Weed Wrote: I agree. In my case I chose to structure rather than a class because it can be initialized at compile time. But now I thing must be allowed to deploy class in the default data segment. And add the possibility of creating a object of class at compile time. If yo

Re: struct inheritance need?

2008-12-17 Thread Kagamin
Weed Wrote: > I agree. > In my case I chose to structure rather than a class because it can be > initialized at compile time. > > But now I thing must be allowed to deploy class in the default data > segment. And add the possibility of creating a object of class at > compile time. If you want

Re: struct inheritance need?

2008-12-16 Thread Weed
alloc scope c2 = new C; // c2 is on stack S s1; // structs default to stack auto s2 = new S; // s2 is S* (heap alloc) I think Andrei said he wants to make changes to "scope", that is IIRC. What will change? struct inheritance, if it gets implemented in D, should express IMO semantics

Re: struct inheritance need?

2008-12-16 Thread Yigal Chripun
new C; // c2 is on stack S s1; // structs default to stack auto s2 = new S; // s2 is S* (heap alloc) I think Andrei said he wants to make changes to "scope", that is IIRC. struct inheritance, if it gets implemented in D, should express IMO semantics similar to concepts as in C++0x, not prov

Re: struct inheritance need?

2008-12-16 Thread Weed
bearophile пишет: > Weed: >> Planned in the future to implement inheritance of structs or the static creation of classes? > > Inheritance of structs: I think it's not planned. Structs in D are meant to be used for different things than classes. > Yet, as time passes structs are gaining more powe

Re: struct inheritance need?

2008-12-16 Thread bearophile
Weed: > Planned in the future to implement inheritance of structs or the static > creation of classes? Inheritance of structs: I think it's not planned. Structs in D are meant to be used for different things than classes. Yet, as time passes structs are gaining more power: you can't believe that

Re: struct inheritance need?

2008-12-16 Thread Weed
Weed пишет: I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runtime. I have decided to make it struct because I ne

Re: struct inheritance need?

2008-12-16 Thread Weed
Bill Baxter пишет: 2008/12/16 Weed : I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runtime. I have decided to m

Re: struct inheritance need?

2008-12-16 Thread Weed
Bill Baxter пишет: 2008/12/16 Weed : I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runtime. I have decided to m

Re: struct inheritance need?

2008-12-16 Thread Bill Baxter
2008/12/16 Weed : > I should explain why it's important for me: > > For example, I am making a matrix object(s) > > It should be: > - any size > - with ability of making matrix instance of a given size in compile time. > - ability of creating matrix instance in runtime. > > I have decided to make i

struct inheritance need?

2008-12-16 Thread Weed
I should explain why it's important for me: For example, I am making a matrix object(s) It should be: - any size - with ability of making matrix instance of a given size in compile time. - ability of creating matrix instance in runtime. I have decided to make it struct because I need to create