Sixth Draft: Primary Type Syntax
IchorDev
zxinsworld at gmail.com
Mon Jan 20 10:53:14 UTC 2025
On Saturday, 18 January 2025 at 05:13:18 UTC, Quirin Schroll
wrote:
> The new section is _[Ambiguities Left to Maximum
> Munch](https://github.com/Bolpat/DIPs/blob/PrimaryTypeSyntax/DIPs/DIP-2NNN-QFS.md#ambiguities-left-to-maximum-munch)._ I added it because Walter strongly suggested me to spell out these details when I attended one of the Monthly Meetings.
First off, I’m still desperate to have this feature! However, I
have a potential syntax improvement for your consideration, with
a bit of preamble:
What if we eventually deprecate the `const(int)*` syntax in a few
editions, or at least prefer for people to use `(const int)*` for
new code? Then the syntax would be more consistent across the
whole language.
However, types like`(const (shared int)*)` present a problem
since they’d be parsed as `const(shared int)*`, leaving people
stuck with a confusing mixture of the two syntaxes; with one
applied as a bandaid over the other.
So, the proposed syntax:
What if a type that is wrapped in parentheses (as in, with no
`TypeCtor` prefix) would not parse the existing `TypeCtor ( Type
)` syntax inside it, instead only using `( Type )`? For example:
`const (shared int)*` const applies to the pointer
`(const (shared int)*)` const doesn’t apply to the pointer
This would keep backwards compatibility but allow the primary
type syntax to be more cohesive. Thoughts?
More information about the dip.development
mailing list