opMixin or mixin function templates with convenience operator?

Paul Backus snarwin at gmail.com
Thu Dec 12 22:17:59 UTC 2019


On Thursday, 12 December 2019 at 22:02:22 UTC, Ola Fosheim 
Grøstad wrote:
> On Thursday, 12 December 2019 at 21:40:33 UTC, Paul Backus 
> wrote:
>> Is there any actual difference between mixing in a bare 
>> expression vs. an immediately-called lambda function that 
>> evaluates to the same expression? Forcing string mixins to 
>> represent lambdas in particular seems needlessly restrictive.
>
> The idea is to prevent writing to variables outside the mixin. 
> So, @pure and const params would perhaps be enough to enable 
> that?

Why is that a desirable goal in the first place? The whole point 
of a string mixin is that it's the same as if you'd typed the 
code yourself. It's the tool you reach for when you need maximum 
expressive power, and nothing else will do.

If what you actually want is a pure const lambda, there's nothing 
stopping you from writing one and sticking your mixin inside it.


More information about the Digitalmars-d mailing list