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: convert char[4] to uint at compile time

2008-12-16 Thread Moritz Warning
On Tue, 16 Dec 2008 19:54:11 +, BCS wrote: > Reply to Moritz, > >> Hi, >> >> I have problems to convert a char[4] to an uint at compile time. All >> variations (I've tried) of using an enum crashes dmd: >> >> union pp { char[4] str; uint num; } >> const uint x = pp("abcd").num >> This does

Re: convert char[4] to uint at compile time

2008-12-16 Thread BCS
Reply to Moritz, Hi, I have problems to convert a char[4] to an uint at compile time. All variations (I've tried) of using an enum crashes dmd: union pp { char[4] str; uint num; } const uint x = pp("abcd").num This does also doesn't work: const uint x = cast(uint) x"aa aa aa aa"; Any ideas?

convert char[4] to uint at compile time

2008-12-16 Thread Moritz Warning
Hi, I have problems to convert a char[4] to an uint at compile time. All variations (I've tried) of using an enum crashes dmd: union pp { char[4] str; uint num; } const uint x = pp("abcd").num This does also doesn't work: const uint x = cast(uint) x"aa aa aa aa"; Any ideas?

Re: confusing (buggy?) closure behaviour

2008-12-16 Thread Zoran Isailovski
Sergey Gromov Wrote: > Sat, 13 Dec 2008 06:59:51 -0500, Zoran Isailovski wrote: > > > Anyway, following the latter pattern, you don't need global analysis. > > You can determine if n is on the stack (it is - it's an argument), > > you can determine if it's referenced from within the closure (it i

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: distinguish between classes and structures

2008-12-16 Thread Weed
Kagamin пишет: Weed Wrote: it is impossible to create the struct of the object which will be arbitrary size (raised by a user) + to be able to set compile-time + should work with the structures of its type. this is mathematical matrix, for example Matix? Easy. class Matrix //can inherit f

Re: distinguish between classes and structures

2008-12-16 Thread Kagamin
Weed Wrote: > it is impossible to create the struct of the object which will be > arbitrary size (raised by a user) + to be able to set compile-time + > should work with the structures of its type. > > this is mathematical matrix, for example Matix? Easy. class Matrix //can inherit from some

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

Re: distinguish between classes and structures

2008-12-16 Thread Weed
Bill Baxter пишет: 2008/12/16 Weed : Frits van Bommel пишет: Weed wrote: In C++, we had the problem - "slicing" objects. In D this problem is solved inability to inherit from structs. Without inheritance of structs many things are not possible, compared with C++. Why, instead of the complete i