Re: Nested Structs (Solution)

2012-12-16 Thread js.mdnq
On Sunday, 16 December 2012 at 01:04:44 UTC, Rob T wrote: There's an interesting discussion going on that may be related to this subject. http://forum.dlang.org/thread/mailman.2705.1355596709.5162.digitalmar...@puremagic.com Note the definition with the "hidden reference frame" baggage, and t

Re: Nested Structs (Solution)

2012-12-15 Thread Rob T
There's an interesting discussion going on that may be related to this subject. http://forum.dlang.org/thread/mailman.2705.1355596709.5162.digitalmar...@puremagic.com Note the definition with the "hidden reference frame" baggage, and to get rid of the extra baggage use "static struct". The r

Re: Nested Structs (Solution)

2012-12-14 Thread js.mdnq
On Friday, 14 December 2012 at 09:47:18 UTC, Rob T wrote: On Friday, 14 December 2012 at 07:39:33 UTC, js.mdnq wrote: Unfortunately it seems we have to make an assignment. A.B!(0) b = a.b1; This one tries to call a constructor that takes in a typeof(a.b1). Do you have a constructor for it?

Re: Nested Structs (Solution)

2012-12-14 Thread Rob T
On Friday, 14 December 2012 at 07:39:33 UTC, js.mdnq wrote: Unfortunately it seems we have to make an assignment. A.B!(0) b = a.b1; This one tries to call a constructor that takes in a typeof(a.b1). Do you have a constructor for it? does not work but A.B!(0) b; b = a.b1; does. Not sure i

Re: Nested Structs (Solution)

2012-12-13 Thread js.mdnq
http://dpaste.dzfl.pl/64025e0a contains updated code. When the offset of the struct is 0 it contains an actual ptr to the class(the standard way) and hence can be "orphaned". When the offset is not 0 then it is part of a class object and can use a calculation to get the parent. Both methods

Re: Nested Structs (Solution)

2012-12-13 Thread js.mdnq
On Friday, 14 December 2012 at 06:27:39 UTC, Rob T wrote: I guess the complicating factor is that a nested struct could not be copied out of one class into another of a different type, so I can see why it's not implemented. The compiler would have to prevent copies out, or the language would ha

Re: Nested Structs (Solution)

2012-12-13 Thread Rob T
I guess the complicating factor is that a nested struct could not be copied out of one class into another of a different type, so I can see why it's not implemented. The compiler would have to prevent copies out, or the language would have to be modified to allow nesting but with some new conve

Re: Nested Structs (Solution)

2012-12-13 Thread js.mdnq
On Thursday, 13 December 2012 at 20:56:05 UTC, Mafi wrote: On Wednesday, 12 December 2012 at 22:58:47 UTC, Max Samukha wrote: On Wednesday, 12 December 2012 at 22:19:54 UTC, js.mdnq wrote: Also, I initially tried to do B!(A.b1.offsetof) b1; a'la http://forum.dlang.org/thread/mailman.

Re: Nested Structs (Solution)

2012-12-13 Thread Mafi
On Wednesday, 12 December 2012 at 22:58:47 UTC, Max Samukha wrote: On Wednesday, 12 December 2012 at 22:19:54 UTC, js.mdnq wrote: Also, I initially tried to do B!(A.b1.offsetof) b1; a'la http://forum.dlang.org/thread/mailman.2627.1355335532.5162.digitalmar...@puremagic.com but dmd 2.

Re: Nested Structs (Solution)

2012-12-13 Thread Rob T
On Thursday, 13 December 2012 at 08:55:44 UTC, js.mdnq wrote: It would be nice if D implements such a feature because it will look more natural. It sure would be nice. With D, you should not have to mess around with a pointer like this. Anyway, thanks for your efforts, we at least have a "ha

Re: Nested Structs (Solution)

2012-12-13 Thread js.mdnq
On Thursday, 13 December 2012 at 01:57:26 UTC, d coder wrote: The name doesn't matter. I just wanted to annoy Walter again with yet another bit of evidence that completeness of a feature is important even if it doesn't seem to have an obvious use case. People will do what is logical and end up

Re: Nested Structs (Solution)

2012-12-12 Thread d coder
> The name doesn't matter. I just wanted to annoy Walter again with yet >> another bit of evidence that completeness of a feature is important even if >> it doesn't seem to have an obvious use case. People will do what is logical >> and end up with hacks like that. >> > I believe it *is* an obvious

Re: Nested Structs (Solution)

2012-12-12 Thread js.mdnq
On Thursday, 13 December 2012 at 00:37:16 UTC, Max Samukha wrote: On Thursday, 13 December 2012 at 00:02:01 UTC, js.mdnq wrote: Half done? Has it even been implemented at all? http://dlang.org/class.html#nested It is implemented for nested classes but not structs. In any case my method se

Re: Nested Structs (Solution)

2012-12-12 Thread Max Samukha
On Thursday, 13 December 2012 at 00:02:01 UTC, js.mdnq wrote: Half done? Has it even been implemented at all? http://dlang.org/class.html#nested It is implemented for nested classes but not structs. In any case my method seems to provide a solution to the problem in the mean time. I have

Re: Nested Structs (Solution)

2012-12-12 Thread js.mdnq
On Wednesday, 12 December 2012 at 22:58:47 UTC, Max Samukha wrote: On Wednesday, 12 December 2012 at 22:19:54 UTC, js.mdnq wrote: Also, I initially tried to do B!(A.b1.offsetof) b1; a'la http://forum.dlang.org/thread/mailman.2627.1355335532.5162.digitalmar...@puremagic.com but dmd 2.

Re: Nested Structs (Solution)

2012-12-12 Thread Max Samukha
On Wednesday, 12 December 2012 at 22:19:54 UTC, js.mdnq wrote: Also, I initially tried to do B!(A.b1.offsetof) b1; a'la http://forum.dlang.org/thread/mailman.2627.1355335532.5162.digitalmar...@puremagic.com but dmd 2.060 crashes, which is why I moved on to using a static if. That's

Re: Nested Structs (Solution)

2012-12-12 Thread js.mdnq
Here is a solution I came up with that seems to work fine and does not require hard coding any values. Hence, it is useable. Unfortunately it looks clunky and is: (and it would be nice to speed up the the method call and possible code it in such a way that if D directly supports this in the fut