On Friday, 30 October 2020 at 23:55:54 UTC, Manu wrote:
>
> I was about to raise both those examples you showed here. I show
> staticMap's implementation right there, and I also show types
> in tuples.
> The trouble as I see is that there's a spec language problem,
> where a tuple
> element is a 'kind of thing' that I don't know what to call
> that.
I think "tuple element" is probably the best you can do. It's a
little clunky, but clunky is better than ambiguous.
If I drop the term "tuple" for "alias sequence", then that results in "alias sequence element", which really doesn't roll off the tongue!
> What do you call this: MyTypeTuple[10] ?
> Is that an index *expression*? Internally, it's an IndexExp,
> but the tuple
> does not have expression elements, so the result is not an
> expression, it's
> a type. I would call that an expression as applied to a tuple
> regardless
> what kind of thing the result is.
> What about this: MyThing.Member <- where Member may be a type.
> Internally
> that's called a DotIdExp... so it's still an expression, even
> if it's
> result is not an expression.
According to the grammar in the language spec, these are both
IdentifierLists [1] when they appear in a context where a type is
expected. In a context where an expression is expected,
`MyTuple[10]` is an IndexExpression [2], and `MyThing.Member` is
a PostfixExpression [3]. There is no such thing as a DotIdExp in
the language spec.
In general, if you need to refer to a particular syntactic
construct, I think it's better to use the name from the language
spec, rather than the DMD-internal class name.
[1] https://dlang.org/spec/grammar.html#IdentifierList
[2] https://dlang.org/spec/grammar.html#IndexExpression
[3] https://dlang.org/spec/grammar.html#PostfixExpression
Is "Alias Sequence" present in spec language?
This really demonstrates how much D needs first-class tuples; this area of the language is a shit-fight, and essentially just a weird abuse of template argument lists mixed with `alias` and some implementation defined behaviour, which happens to look and feel a lot like a tuple.