Phobos: __FILE__ as template default parameter

David Nadlinger via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 21 03:39:52 PDT 2016


On Monday, 20 June 2016 at 08:10:19 UTC, Dicebot wrote:
> How about defining semantics like "try inlining if possible, 
> fallback to always emitting symbol to object file otherwise"? 
> That would also allow compatible implementation in dmd.

This would get rid of the undefined symbols, but there is a much 
more subtle problem here that nobody has brought up yet: If the 
template ends up being emitted twice with different mangled 
names, then, well, it ends up existing twice in the final 
executable.

This is not really an issue for functions, but very much so for 
data symbols (e.g. a static variable inside a function), where 
you could end up with the same alias referring to two different 
pieces of data depending on where it is used from.

The root of this issue is that __FILE__ introduces incidental 
environmental state into the otherwise pure module system.

  — David


More information about the Digitalmars-d mailing list