D Language Foundation November 2025 Monthly Meeting Summary

Nick Treleaven nick at geany.org
Wed May 6 11:30:15 UTC 2026


On Wednesday, 6 May 2026 at 10:44:18 UTC, Dennis wrote:
> On Monday, 4 May 2026 at 15:41:46 UTC, Kagamin wrote:
>> If explicit this is a parser change, what difference does it 
>> make? Just for AST to be a uniform array of arguments?
>
> The goal is to make the syntax clearer, because currently it 
> often looks like the attributes apply to the return value 
> instead of `this`.
>
> ```D
> struct S
> {
>     int x;
>     int* y;
>
>     const int f() => this.x; // returns const(int)?
>     scope int* g() => null; // returns a scoped pointer?
>     ref int h() return => this.x; // 'return' what?
> }
> ```

It's already good practice to put `const` and `scope` after the 
parameter list. It's true `return` could be clearer - we could 
require `return ref` instead:

```d
     int f() const => this.x;
     int* g() scope => null;
     ref int h() return ref => this.x; // return ref to this
```

Although non-`this` attributes are allowed after the parameter 
list too.

> With explicit this, the code becomes:
>
> ```D
> struct S
> {
>     int x;
>     int* y;
>
>     int f(const ref S this) => this.x;
>     int* g(scope ref S this) => null;
>     ref int h(return ref S this) => this.x;
> }
> ```

That's more verbose, and it seems less consistent to me with mass 
applying attributes to declarations e.g. `const:`. Also why 
repeat S? Can we declare a method that takes a struct `this` by 
value by leaving off `ref` (which could be useful for small 
structs)? Would people accidentally do that when they wanted 
`ref`?


More information about the Digitalmars-d-announce mailing list