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:
```d
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:

```d
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:
```d
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.

Reply via email to