On Monday, 4 May 2020 at 11:50:49 UTC, Steven Schveighoffer wrote:
I'm not sure if Ali is referring to this, but the usage of
scope to allocate on the stack was at one time disfavored by
the maintainers. This is why std.typecons.scoped was added (to
hopefully remove that feature).
Though, if
On Mon, May 04, 2020 at 09:33:27AM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> Now it's news to me that 'new' does not allocate on the heap when
> 'scope' is used. I'm not sure I'm comfortable with it but that's true.
> Is this unique? Otherwise, 'new' always allocates on the heap,
On 5/4/20 12:33 PM, Ali Çehreli wrote:
Now it's news to me that 'new' does not allocate on the heap when
'scope' is used. I'm not sure I'm comfortable with it but that's true.
Is this unique? Otherwise, 'new' always allocates on the heap, no?
This feature was in D1 AFAIK.
So it's really old n
On 5/4/20 2:47 AM, Olivier Pisano wrote:
On Monday, 4 May 2020 at 09:20:06 UTC, Ali Çehreli wrote:
On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at
16:55:36 UTC, Robert M. Münch wrote:
> I think you want to use scope rather than auto which will put
the class
> on the stack
On 5/4/20 5:47 AM, Olivier Pisano wrote:
On Monday, 4 May 2020 at 09:20:06 UTC, Ali Çehreli wrote:
On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at
16:55:36 UTC, Robert M. Münch wrote:
> I think you want to use scope rather than auto which will put
the class
> on the stack
On Monday, 4 May 2020 at 09:20:06 UTC, Ali Çehreli wrote:
On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April
2020 at 16:55:36 UTC, Robert M. Münch wrote:
> I think you want to use scope rather than auto which will put
the class
> on the stack and call its destructor:
> https://dlang.o
On 4/30/20 10:04 AM, Ben Jones wrote:> On Thursday, 30 April 2020 at
16:55:36 UTC, Robert M. Münch wrote:
> I think you want to use scope rather than auto which will put the class
> on the stack and call its destructor:
> https://dlang.org/spec/attribute.html#scope
That is correct about calling
On 2020-05-02 20:43:16 +, Steven Schveighoffer said:
destroy sets all the values to the .init value. And it nulls the vtable
pointer.
Ok, that makes sense. Thanks for all the deep internal details. There
is always a lot to learn.
--
Robert M. Münch
http://www.saphirion.com
smarter | bet
On 5/2/20 3:08 PM, Robert M. Münch wrote:
On 2020-05-02 18:18:44 +, Steven Schveighoffer said:
On 5/2/20 4:44 AM, Robert M. Münch wrote:
How would that help, because the class instance is now unusable
anyway. So I have it around like a zombie and others might think:
"Hey you look normal,
On 2020-05-02 18:18:44 +, Steven Schveighoffer said:
On 5/2/20 4:44 AM, Robert M. Münch wrote:
How would that help, because the class instance is now unusable anyway.
So I have it around like a zombie and others might think: "Hey you look
normal, let's get in contact" and then you are doo
On 5/2/20 4:44 AM, Robert M. Münch wrote:
On 2020-04-30 17:45:24 +, Steven Schveighoffer said:
You can use scope instead of auto, and it will then allocate the class
on the stack, and destroy it as Ben Jones said. There is danger there,
however, as it's very easy to store a class reference
On 2020-04-30 17:45:24 +, Steven Schveighoffer said:
No, auto is declaring that there's about to be a variable here. In
actuality, auto does nothing in the first case, it just means local
variable. But without the type name, the type is inferred (i.e. your
second example). This does not do
On 2020-04-30 17:04:43 +, Ben Jones said:
I think you want to use scope rather than auto which will put the class
on the stack and call its destructor:
https://dlang.org/spec/attribute.html#scope
Yes, thanks.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
On 4/30/20 12:55 PM, Robert M. Münch wrote:
For ressource management I mostly use this pattern, to ensure the
destructor is run:
void myfunc(){
MyClass X = new MyClass(); scope(exit) X.destroy;
}
I somewhere read, this would work too:
void myfunc(){
auto MyClass X = new MyClass();
}
What
On Thursday, 30 April 2020 at 16:55:36 UTC, Robert M. Münch wrote:
For ressource management I mostly use this pattern, to ensure
the destructor is run:
void myfunc(){
MyClass X = new MyClass(); scope(exit) X.destroy;
}
I somewhere read, this would work too:
void myfunc(){
auto MyClass X = n
For ressource management I mostly use this pattern, to ensure the
destructor is run:
void myfunc(){
MyClass X = new MyClass(); scope(exit) X.destroy;
}
I somewhere read, this would work too:
void myfunc(){
auto MyClass X = new MyClass();
}
What does this "auto" does here? Wouldn't
void myf
16 matches
Mail list logo