Scope of Mixins
Paul Backus
snarwin at gmail.com
Thu Aug 26 16:25:17 UTC 2021
On Thursday, 26 August 2021 at 16:16:55 UTC, DLearner wrote:
> Please confirm that mixins of format:
> ```
> string mxn1(string VarName) {
> ...
> }
> ```
> Invoked like:
> ```
> mixin(mxn1("Var1"));
> ```
>
> Have a wider scope than mixins like:
> ```
> string mxn2(string VarName)() {
> ...
> }
> ```
> Invoked like:
> ```
> mixin(mxn2!"Var2");
> ```
If the strings produced by `mxn1("Var1")` and `mxn2!"Var2"` are
the same, mixing them in will have the same result. `mixin()`
does not care where the string you pass to it comes from.
> I tried direct replacement of former by the latter, could not
> get clean compile until definition moved into same module.
Something you are doing in the body of the functions is causing
this, but because you have not included function bodies in your
post, I cannot tell you what.
More information about the Digitalmars-d-learn
mailing list