On Thursday, 10 May 2018 at 14:30:49 UTC, Seb wrote:
On Thursday, 10 May 2018 at 14:15:18 UTC, Yuxuan Shui wrote:
So in D I can use default argument like this:

int f(int line=__LINE__) {}

[...]

Why not define a TLS or global variable like theAllocator?
Or if you know it at compile-time as an alias?

Because my proposal is better encapsulated. Definitions of expanded default arguments are scoped, so in the given example, you can have different __ALLOC__ in different scope, where different allocators might be needed.

My proposal is basically an alias, but an alias which is recognized by compiler as subtitution keywords for default arguments (like __LINE__, __FILE__).

Reply via email to