Multiple alias this, what's the hold up?
Timon Gehr
timon.gehr at gmx.ch
Mon Jun 17 18:15:54 UTC 2019
On 17.06.19 09:29, Walter Bright wrote:
> On 6/16/2019 4:46 PM, Timon Gehr wrote:
>> mixin(import("std/stdio.d"));
>
> Template mixins are something else:
>
> https://dlang.org/spec/template-mixin.html
In my answer I explicitly stated that for the purpose of my argument,
mixing in commutes with parsing. There isn't an obvious way to turn a
module into a mixin template, so it was easier to make my point with a
string mixin.
To elaborate on my previous preemptive strike against your complaint,
from that page of the spec:
"Unlike a template instantiation, a template mixin's body is evaluated
within the scope where the mixin appears, not where the template
declaration is defined."
This is not how `alias this` works. I know that importing a scope is
part of how the `mixin` template is implemented. What I am saying is
`alias this` should use the same kind of lookup rules, but without the
mixing in -- only the importing.
PS: And anyhow, how ironic! :)
- I know what template mixins are. I implemented [1] them in a D
compiler frontend. I know that importing [2] the _newly generated_ scope
is one step in the implementation.
- In general, I know most of the language spec by heart. I also know
about almost all aspects of D semantics that are missing or wrong in the
language specification.
[1] https://github.com/tgehr/d-compiler/blob/master/semantic.d#L3308
[2] https://github.com/tgehr/d-compiler/blob/master/semantic.d#L3348
More information about the Digitalmars-d
mailing list