RFC: Last words on Primary Type Syntax aka. `ref` return function pointer type sytnax

IchorDev zxinsworld at gmail.com
Fri Jul 4 12:27:51 UTC 2025


On Thursday, 3 July 2025 at 17:31:17 UTC, Quirin Schroll wrote:
> A more relevant example would be an array or slice of function 
> pointers. There’s a stylistic urge to write `(void 
> function())[]` instead of `void function()[]`, but the proposed 
> parsing rule locks one in: With `scope`, it’s `scope void 
> function()[]` without `ref` and `scope (ref void function())[]` 
> or `scope (ref void function()[])`, but not `scope ((ref void 
> function())[])` with `ref`. The last one is excluded because, 
> given the inner parentheses, the outer ones aren’t required 
> anymore.

Walter, no! Don’t do this to the beautiful primary type syntax! 
My head hurts reading this mess of confusion! Why is adding 
superfluous parenthesis disallowed?? Why don’t we add this 
behaviour binary expressions too?!
```d
auto a = (1 * 2) + 3; //ERROR: 1 * 2 would already be performed 
first and therefore must not be parenthesised
```
There is nothing wrong with the proposed syntax except that it is 
a bandaid solution to a larger syntactical blunder: `ref` needs 
to be able to mean multiple things within the same context


More information about the Digitalmars-d mailing list