Discussion Thread: DIP 1037--Add Unary Operator ...--Community Review Round 1
Manu
turkeyman at gmail.com
Sat Oct 31 23:09:31 UTC 2020
On Sat, Oct 31, 2020 at 12:05 PM Paul Backus via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20201101/94ed69a5/attachment-0001.htm>
More information about the Digitalmars-d
mailing list