D needs a type expression syntax
Nick Treleaven
nick at geany.org
Sat May 13 11:13:59 UTC 2023
On Monday, 8 May 2023 at 17:02:07 UTC, Quirin Schroll wrote:
> 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.
Just noticed we have this form for function literals:
```
function RefOrAutoRefopt Typeopt ParameterWithAttributesopt
FunctionLiteralBody2
```
https://dlang.org/spec/expression.html#function_literals
But for function types we have just:
```
TypeCtorsopt BasicType function Parameters FunctionAttributesopt
```
https://dlang.org/spec/type.html (inlining the *TypeSuffix* form)
It seems we could add this form to *Type* for consistency with
function literals:
```
function RefOrAutoRefopt Type ParameterWithAttributes
```
So this works:
`void f(function ref int() g);`
And add a similar type for delegates:
```
delegate RefOrAutoRefopt Type ParameterWithMemberAttributes
```
That would be a smaller impact change than parenthesized types.
More information about the Digitalmars-d
mailing list