What's the issue(s) with scope vars?

Nick Sabalausky via Digitalmars-d digitalmars-d at puremagic.com
Thu May 22 13:05:23 PDT 2014


On 5/22/2014 3:39 PM, Dicebot wrote:
>
> Second question - that is something yet to investigate. Natural relation
> between those is that value captured by `scoped` should be qualified as
> `scope` to be reliably memory safe. Does that also mean that you can
> skip `scoped` altogether and release all scope variables at the end of
> scope automatically? Something yet to investigate.

Ooh, looking at the docs for phobos scoped now, I see it's mainly just 
for emplacing a class on the stack, and doesn't prevent escaping at all. 
I'm understanding it better now.

I had thought there was something in phobos that worked for structs, 
preventing escaping by disabling postblit and then guaranteeing 
destruction at the end of the defining scope - or something vaguely like 
that anyway. But I think I was confusing several different things such 
as scoped, emplace and RefCOunted.


More information about the Digitalmars-d mailing list