What is the state of @property?

Salih Dincer salihdb at hotmail.com
Sun Aug 28 19:16:15 UTC 2022


On Sunday, 28 August 2022 at 15:36:41 UTC, Steven Schveighoffer 
wrote:
> In all other cases, it's indistinguishable from a normal 
> function/method.

We still need @property where specified 
[here](https://dlang.org/spec/type.html#typeof) **⁵**.  When you 
compile the example in the code window below, you get the 
following error:

> onlineapp.d(17): Error: variable `onlineapp.main.test1` cannot 
> be declared to be a function

```d
struct S {
   //@property
   float Float() {
     return .0;
   }

   @property
   double Double() {
     return .0;
   }
}

void main()
{
     S s;

     typeof(s.Float) test1 = s.Float;
     typeof(s.Double) test2 = s.Double;

     import std.stdio;

     typeid(test1).writeln(": ", test1);
     typeid(test2).writeln(": ", test2);
}
```

This is what I wanted to talk about above.  So it changes dignity 
of function (correct word?).

SDB at 79



More information about the Digitalmars-d mailing list