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 s

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 show a

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 providing a use case, though. Why not show an exam

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
Weed пишет: 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 ot

Re: struct inheritance need?

2008-12-17 Thread Weed
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 wi

Re: struct inheritance need?

2008-12-17 Thread Weed
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 wi

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
Yigal Chripun пишет: If I understand you correctly - I think you confuse here two separate and orthogonal issues. 1) struct vs. class 2) memory allocation What D tries to do is to provide types with value semantics via structs and types with reference semantics _and_polymorphism_ via classe

Re: struct inheritance need?

2008-12-16 Thread Yigal Chripun
Weed wrote: 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 g

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