First Draft: Static Single Assignment

Nick Treleaven nick at geany.org
Tue Nov 18 22:09:56 UTC 2025


On Tuesday, 18 November 2025 at 17:05:56 UTC, Tim wrote:
> For full C++ interop it would also be needed for the hidden 
> `this` parameter of methods,

I think the `this` reference is already essentially `final` in a 
D class. Do you mean for a struct so its fields are head const?

> but `final` on methods already means something different:
> ```
> extern(C++) class C
> {
>     void f() final; // Does final mean head const here?
> }
> ```
>
> The syntax could distinguish between `final` before and after 
> the declaration, but that could be confusing. It would be 
> better to use a different keyword for head const with C++ 
> compatibility.

Walter supports* allowing explicit `this` parameters, which could 
solve the ambiguity if the `final` attribute on a method always 
means 'not overridable'. So to mark the `this` parameter as 
`final` you would have to declare it as the first parameter.

*https://forum.dlang.org/post/10004mc$23m1$1@digitalmars.com


More information about the dip.development mailing list