Why is this not allowed?
Steven Schveighoffer
schveiguy at gmail.com
Tue Oct 8 16:48:55 UTC 2024
On Tuesday, 8 October 2024 at 15:10:54 UTC, ryuukk_ wrote:
>
> Nonono, you overthink it
>
> Store last anonamous struct
>
> When you see a field without a type, you assign it with that
> anonymous struct
It doesn't work this way. The parser would have to lookahead to
see if the next 2 tokens are an identifier and semicolon. And
then close out the declaration in that case.
It could possibly be unambiguous, but I suspect there may be
ambiguities with current grammar.
D grammar is *mostly* free of lookahead, but there are
exceptions. It keeps things cleaner.
I'm not saying I don't want this kind of feature, I'm saying I
think you need new syntax. What's wrong with new syntax? This in
itself is new syntax (to D).
I've asked for struct lambdas in the past, in the context of
passing a model to a template. This would be similar.
-Steve
More information about the Digitalmars-d-learn
mailing list