Re: Create class on stack

2017-08-08 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 7 August 2017 at 13:40:18 UTC, Moritz Maxeiner wrote: Thanks, I wasn't aware of this. I tried fooling around scope classes and DIP1000 for a bit and was surprised that this is allowed: Thanks for the test case :-) It was fun to see that ASan can catch this bug too. Because

Re: Create class on stack

2017-08-08 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 05:37:41 UTC, ANtlord wrote: On Sunday, 6 August 2017 at 15:47:43 UTC, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been > scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years),

Re: Create class on stack

2017-08-07 Thread ANtlord via Digitalmars-d-learn
On Sunday, 6 August 2017 at 15:47:43 UTC, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been > scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though. [1]

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 22:02:07 UTC, Mike wrote: On Monday, 7 August 2017 at 13:42:33 UTC, Moritz Maxeiner wrote: You can still create a (scope) class on the stack, escape a reference to it using `move` and use it afterwards, all within the rules of @safe, so I'm not convinced that the

Re: Create class on stack

2017-08-07 Thread Mike via Digitalmars-d-learn
On Monday, 7 August 2017 at 13:42:33 UTC, Moritz Maxeiner wrote: You can still create a (scope) class on the stack, escape a reference to it using `move` and use it afterwards, all within the rules of @safe, so I'm not convinced that the reason for deprecating scoped classes is gone yet.

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 10:42:03 UTC, Jacob Carlborg wrote: On 2017-08-06 17:47, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though. It's

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 13:40:18 UTC, Moritz Maxeiner wrote: Thanks, I wasn't aware of this. I tried fooling around scope classes and DIP1000 for a bit and was surprised that this is allowed: --- import core.stdc.stdio : printf; import std.algorithm : move; class A { int i;

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 10:50:21 UTC, Mike wrote: On Sunday, 6 August 2017 at 15:47:43 UTC, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though.

Re: Create class on stack

2017-08-07 Thread Mike via Digitalmars-d-learn
On Sunday, 6 August 2017 at 15:47:43 UTC, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though. [1]

Re: Create class on stack

2017-08-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-06 17:47, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though. It's used all over the place in the DMD code base. -- /Jacob Carlborg

Re: Create class on stack

2017-08-06 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 6 August 2017 at 15:24:55 UTC, Jacob Carlborg wrote: On 2017-08-05 19:08, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since

Re: Create class on stack

2017-08-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-05 19:08, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like to minimize unnecessary

Re: Create class on stack

2017-08-06 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote: [...] I don't think you understand what I'm saying. If I use this method to create a "reference" type on the stack rather than the heap, is the only issue worrying about not having that variable be used outside that scope(i.e., have

Re: Create class on stack

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:32:05 UTC, Adam D. Ruppe wrote: On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote: Also, does it do the allocation at compile time(reserve space on the stack for the variable along with all the others or does it "allocate" space on the stack at

Re: Create class on stack

2017-08-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote: Also, does it do the allocation at compile time(reserve space on the stack for the variable along with all the others or does it "allocate" space on the stack at runtime?... which is slightly slower). compile time. It works like a

Re: Create class on stack

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:10:31 UTC, Moritz Maxeiner wrote: On Sunday, 6 August 2017 at 01:18:50 UTC, Johnson Jones wrote: On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote: On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called

Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 6 August 2017 at 01:18:50 UTC, Johnson Jones wrote: On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote: On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a

Re: Create class on stack

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote: On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to

Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like

Re: Create class on stack

2017-08-05 Thread angel via Digitalmars-d-learn
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like

Create class on stack

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like to minimize unnecessary allocations. Is there any way to get D to