D needs a type expression syntax

Quirin Schroll qs.il.paperinik at gmail.com
Mon May 8 17:02:07 UTC 2023


On Sunday, 7 May 2023 at 00:14:35 UTC, Walter Bright wrote:
> On 5/6/2023 8:55 AM, Quirin Schroll wrote:
>> I have a very stupid question now: Why does a minor grammar 
>> change require a DIP? How do people determine what is an 
>> enhancement and what requires a DIP?
>
> It's not a stupid question at all.
>
> The reason is, it is definitely non-trivial, it will impact a 
> lot of code with deprecations, people will want a strong 
> explanation of why this is worthwhile, and enable a wider 
> audience to look for risks and flaws.

Thank you for responding.

The proposal can be summed up as:
1. Allow `TypeCtor` in the `TypeCtor(Type)` of `BasicType` syntax 
to be “mutable,” which is syntactically just nothing, i.e. allow 
`BasicType` to be `(Type)`.
2. Allow `ref` as the initial token for a type; such a type must 
be a `function` or `delegate` type to make sense.

They’re even orthogonal: The first clearly does not depend on the 
second and even the second does not depend on the first, but they 
really shine together.

My post was mostly about motivation, why this is useful/necessary 
and that, albeit it sounds big, is actually quite a small change.

> At a first reading, this looks like a worthwhile endeavor.

This is probably about changing a few lines of code in the 
parser, without any (big) additions.

> But the thing is, what you've written is already pretty close 
> to being a DIP. You've already done the hard part.
>
> One question: can this peacefully coexist with the existing 
> syntax, before we push it with a deprecation?

Yes. This was essentially asked by Basile B. and the answer is 
that the deprecations are entirely optional. They’re like 
deprecating `() => { }` (for creating nested lambdas) or, even 
closer, not allowing bit-operators and comparison operators 
without clarifying parentheses.

I suggested them because I think that confusing syntax should 
only be allowed if truly the lesser of two evils. Demanding 
clarifying parentheses is not horrible breakage.

We can 100% implement the feature today and discuss the 
deprecations in the next years or so.


More information about the Digitalmars-d mailing list