June 22, 2016
On Tuesday, 21 June 2016 at 10:39:52 UTC, David Nadlinger wrote:
> 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.

+1

July 05, 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.
>
> My reasoning for proposing that is that for all legitimate cases I'd have to use __FILE__ as a template argument I'd also want the symbol inlined to prevent the bloat. After all CT computation such functions tend to contain 1-2 lines of runtime code only.

In LDC, Phobos functions with __FILE__ as default template parameter value are now marked with `pragma(inline, true)`, as a workaround for the larger issue of what to do with __FILE__ as template parameter.
https://github.com/ldc-developers/phobos/commit/8b2052cffe159be3db7debbe28ee967630cb4588

(the issue was preventing cross-module inlining, so a workaround was needed)
1 2 3
Next ›   Last »