How to specity a list of fields with default to a mixin template?

realhet real_het at hotmail.com
Wed Mar 26 19:20:56 UTC 2025


On Sunday, 2 March 2025 at 23:28:09 UTC, Inkrementator wrote:
> On Sunday, 2 March 2025 at 19:31:06 UTC, realhet wrote:
>> Anyone have an idea?
>
> While template mixins have access to the caller scope, the 
> default values for parameters apparently don't.

Thank you, both of you!

That was the key to a successful solution, that the mixin 
template's surface have access to the caller scope.

So I ended up with two separate string mixins:
* The 1st injects a dummy declaration using the string 
definitions.
* The 2nd analizes the declaration and injects the final 
generated code based on that.

It was also important to separate the two things into two mixins. 
  This must be because multipass processing.  The second's first 
pass must access the result of the first's last pass, I guess.


I will also remember that mixin("import ") trick.  Dangerous but 
powerful stuff.


More information about the Digitalmars-d-learn mailing list