RFC: DIP draft for "Compiler-defined Attribute Consistency"

Dennis dkorpel at gmail.com
Wed Jul 14 17:02:48 UTC 2021


On Wednesday, 14 July 2021 at 16:55:30 UTC, Ogi wrote:
> Except when they are attributes — when applied to member 
> functions.

No, then they are still type constructors. This:

```D
struct S {
     void f() const {

     }
}
```
Is roughly equal to this:

```D
void f(ref const S this) {

}
```

> It makes no sense that `const int` variable is a constant 
> integer while `const int function()` is a constant member 
> function of some struct or class that returns non-constant 
> integer.

return, scope, const, inout, immutable, shared outside the 
parameter list all apply to the implicit `this` parameter. The 
syntax is confusing, but there are multiple solutions. Adding `@` 
variants for all type constructors is one of them, but that 
doesn't make it relevant to a DIP about function attributes.



More information about the Digitalmars-d mailing list