Re: move object from heap to stack

2012-09-20 Thread monarch_dodra
On Wednesday, 19 September 2012 at 21:36:56 UTC, Namespace wrote: I count it to destroy it if it isn't used anymore. What I'm saying though is that when your stacked_obj goes out of scope, it gets destroyed, 100% of the time. The chunk disappears, along with any object inside it. When that

Re: move object from heap to stack

2012-09-20 Thread monarch_dodra
On Thursday, 20 September 2012 at 08:10:36 UTC, Namespace wrote: You're right. This is my next try: http://dpaste.dzfl.pl/02b32d33 Do you have anything else to say? :) I think it looks good, but I'm unsure about move, or allowing pass by value: Classes can't be memcopied the way structs

Re: move object from heap to stack

2012-09-20 Thread Johannes Pfau
Am Thu, 20 Sep 2012 10:11:37 +0200 schrieb Namespace rswhi...@googlemail.com: You're right. This is my next try: http://dpaste.dzfl.pl/02b32d33 Do you have anything else to say? :) I think it shouldn't be possible to copy an OnStack struct. The destructor is run for every copy, but the

Re: move object from heap to stack

2012-09-20 Thread Johannes Pfau
Am Thu, 20 Sep 2012 12:06:28 +0200 schrieb monarch_dodra monarchdo...@gmail.com: On Thursday, 20 September 2012 at 08:10:36 UTC, Namespace wrote: You're right. This is my next try: http://dpaste.dzfl.pl/02b32d33 Do you have anything else to say? :) I think it looks good, but I'm unsure

Re: move object from heap to stack

2012-09-20 Thread Namespace
So I should disable the copy ctor (@disable this(this)) and drop move, right? As you can See if I pass a OnStack to function/class i'm using .get all the Time. The only other method IMO would be to pass it as OnStack by value and Store it in the other class also as OnStack, right?

Re: move object from heap to stack

2012-09-20 Thread monarch_dodra
On Thursday, 20 September 2012 at 12:32:03 UTC, Namespace wrote: So I should disable the copy ctor (@disable this(this)) and drop move, right? Yes, but at that point, what you have is scoped!T re-implemented :/ As you can See if I pass a OnStack to function/class i'm using .get all the Time.

Re: move object from heap to stack

2012-09-20 Thread Namespace
On Thursday, 20 September 2012 at 14:02:01 UTC, monarch_dodra wrote: On Thursday, 20 September 2012 at 12:32:03 UTC, Namespace wrote: So I should disable the copy ctor (@disable this(this)) and drop move, right? Yes, but at that point, what you have is scoped!T re-implemented :/ As you can

Re: move object from heap to stack

2012-09-20 Thread monarch_dodra
On Thursday, 20 September 2012 at 14:09:29 UTC, Namespace wrote: http://dpaste.dzfl.pl/edit/361a54eb With [code] @disable this(this); [/code] this don't work (as expected). But with the copy ctor but without .get you earn a segmentation fault (as you can see). So you can disable the copy ctor

Re: move object from heap to stack

2012-09-20 Thread Namespace
On Thursday, 20 September 2012 at 14:15:23 UTC, monarch_dodra wrote: On Thursday, 20 September 2012 at 14:09:29 UTC, Namespace wrote: http://dpaste.dzfl.pl/edit/361a54eb With [code] @disable this(this); [/code] this don't work (as expected). But with the copy ctor but without .get you earn a

Re: move object from heap to stack

2012-09-20 Thread monarch_dodra
On Thursday, 20 September 2012 at 15:04:48 UTC, Namespace wrote: On Thursday, 20 September 2012 at 14:15:23 UTC, monarch_dodra wrote: On Thursday, 20 September 2012 at 14:09:29 UTC, Namespace wrote: http://dpaste.dzfl.pl/edit/361a54eb With [code] @disable this(this); [/code] this don't work

Re: move object from heap to stack

2012-09-20 Thread Namespace
I expect nothing, my only intention was to show you, that this cannot work. But that it works with an explicit cast is very impressive. I thought the alias this does it automatically. I'm learning too. ;)

move object from heap to stack

2012-09-19 Thread Namespace
Is that possible? I can initialize an object with scope or, in feature, with scoped, directly on the stack but is it also possible to move an existing object from the heap to the stack?

Re: move object from heap to stack

2012-09-19 Thread Namespace
On Wednesday, 19 September 2012 at 13:32:42 UTC, Namespace wrote: Is that possible? I can initialize an object with scope or, in feature, with scoped, directly on the stack but is it also possible to move an existing object from the heap to the stack? I tried this:

Re: move object from heap to stack

2012-09-19 Thread Simen Kjaeraas
On Wed, 19 Sep 2012 15:45:21 +0200, Namespace rswhi...@googlemail.com wrote: On Wednesday, 19 September 2012 at 13:32:42 UTC, Namespace wrote: Is that possible? I can initialize an object with scope or, in feature, with scoped, directly on the stack but is it also possible to move an

Re: move object from heap to stack

2012-09-19 Thread Namespace
Thanks, I will use __traits(classInstanceSize, A); But it does not work either.

Re: move object from heap to stack

2012-09-19 Thread Namespace
On Wednesday, 19 September 2012 at 17:08:28 UTC, monarch_dodra wrote: On Wednesday, 19 September 2012 at 14:16:31 UTC, Namespace wrote: Thanks, I will use __traits(classInstanceSize, A); But it does not work either. This is because classes are already pointers. when you write a, you are

Re: move object from heap to stack

2012-09-19 Thread Namespace
Result: http://dpaste.dzfl.pl/24988d8f

Re: move object from heap to stack

2012-09-19 Thread monarch_dodra
On Wednesday, 19 September 2012 at 19:24:34 UTC, Namespace wrote: Result: http://dpaste.dzfl.pl/24988d8f I like it, but how can something placed on the stack be reference counted? The chunk is also placed on the stack, so it doesn't really make sense to me: When the object goes out of scope,