why allocators are not discussed here

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Jun 26 14:22:32 PDT 2013


27-Jun-2013 01:05, Adam D. Ruppe пишет:
> On Wednesday, 26 June 2013 at 21:00:54 UTC, Dmitry Olshansky wrote:
>> Just don't use certain built-ins. Stub them out in run-time if you
>> like. The only problematic point I see is closures allocated on heap.
>
> Actually, I was kinda sorta able to solve this in my minimal d.
>
> // this would be used for automatic heap closures, but there's no way to
> free it...

[snip a cool hack]

Yeah, I suspected something like this might work. Basically defining 
your own ref-count closure type and forging delegate keyword in your 
codebase (except in the file that defines heap closure). That still 
leaves chasing code like auto dg = (...){ ... } though.

Maybe having it as a template Closure!(ret-type, arg types...)
and instantiator function called simply closure could be more
ecstatically pleasing (this is IMHO).

> It worked in my toy tests. The trick would be though to never store or
> use a non-scope builtin delegate. Using RTInfo, I believe I can
> statically verify you don't do this in the whole program,  but haven't
> actually tried yet.
>
>
> I also left built in append unimplemented, but did custom types with ~=
> that are pretty convenient. Binary ~ is a loss though, too easy to lose
> pointers with that.


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list