June 15

On Saturday, 14 June 2025 at 23:49:19 UTC, Steven Schveighoffer wrote:

>

A lambda is a shortened syntax for a function literal or delegate literal.

HOWEVER, when you do not give the parameters types, the lambda becomes a template! Well, not actually a template, but a quasi-template.

An untyped parameter does make the literal an actual template:

pragma(msg, __traits(isTemplate, (x) {})); // true

It can be instantiated with a type parameter.

https://dlang.org/spec/expression.html#function-literal-alias

>

If you add types to your lambda, then the compiler can figure it out:

mixin f!((S _) {});
mixin f!((S _) => 0);

These are now no longer templates, but instead concrete function literals.

When there are no parameters, a literal is not a template:

pragma(msg, __traits(isTemplate, () {})); // false

alias f = () {};
pragma(msg, is(typeof(*f) == function)); // true

So I think there must be another reason why your unary literals work.

June 15

On Sunday, 15 June 2025 at 10:51:37 UTC, Nick Treleaven wrote:

>

So I think there must be another reason why your unary literals work.

Given it's specifically void return, and top level and it acts like it matches the first return, I expect that void is incorrectly being considered a invalid return type thru 1 very specific pathway of the compiler

June 15

On Sunday, 15 June 2025 at 10:51:37 UTC, Nick Treleaven wrote:

>

An untyped parameter does make the literal an actual template:

pragma(msg, __traits(isTemplate, (x) {})); // true

It can be instantiated with a type parameter.

Therefore in the case discussed, the code `(_){}' declares a template. This template is used as an actual parameter to a parameterized mixin.

If used and in general, templates must be instantiated and the instantiatons stored for later use.

It seems, that for a parameterized mixin those actual instantiatons are not deleted when they do not conform with the formal parameter of the mixin.

5 days ago

On Sunday, 15 June 2025 at 16:14:28 UTC, Manfred Nowak wrote:

>

On Sunday, 15 June 2025 at 10:51:37 UTC, Nick Treleaven wrote:

>

An untyped parameter does make the literal an actual template:

pragma(msg, __traits(isTemplate, (x) {})); // true

It can be instantiated with a type parameter.

Therefore in the case discussed, the code `(_){}' declares a template. This template is used as an actual parameter to a parameterized mixin.

Yes, sorry I misread.

1 2
Next ›   Last »