Complicated @property access only works when I write an extra parenthesis "()"

realhet real_het at hotmail.com
Fri May 26 21:29:06 UTC 2023


On Friday, 26 May 2023 at 21:00:20 UTC, realhet wrote:

Update:
```
auto x = karcSamples[a.key].lod0;	print(x._size);
auto y = karcSamples[a.key].lod0();	print(y._size);
with(karcSamples[a.key].lod0) print(_size);
with(karcSamples[a.key].lod0()) print(_size);
```
When I put it into a temp variable or inside a with(), then both 
form works ok.

Bit when I try to write the whole thing in a single nice 
expression: No property `_size` for the type `void`.

In the documentation I see this:
- For the expression typeof(exp) where exp is an @property 
function, the type is the return type of the function, rather 
than the type of the function.
- For the expression __traits(compiles, exp) where exp is an 
@property function, a further check is made to see if the 
function can be called.

I think this extra step is not always working and by writing an 
extra () or by using a temp variable or a with(), I was able to 
force it.  I only hope there is a workaround that I can implement 
inside my template things, so the business logic could be nice as 
it can be...


More information about the Digitalmars-d-learn mailing list