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

realhet real_het at hotmail.com
Fri May 26 21:00:20 UTC 2023


Hello,

I tried to narrow the problem and make a small example, but I've 
failed.

I try to describe the syndrome, maybe someone knows about it.
(I heard that @properties are not 100% functional, maybe it's 
because of that, I dunno...)

With pragma msg, I verify the time of things:

karcSamples
This is a class, I create it from a class template, which has a 
lot of template mixins inside.

karcSamples[key]
The type of this is a RecordAccessor struct, which is a Voldemort 
struct inside a function. That function is called by 
karcSamples.opIndex(key).

karcSamples[key].lod0
The type of this is BlobLoader
'lod0' is a mixin generated @property getter. It calls a template 
function in the karcSamples class: _getBlob!"lod0"(key)  this 
also calls an internal struct called DataLoggerBlobAA which is 
acting like an associative array.  That iternal struct overloads 
the opBinary!"in" operator and returns a BlobLoader struct.

karcSamples[key].lod0._size    ->   _error_     void has no 
property ._size
But this is weird, because BlobLoader actually HAS a @property 
called _size.

karcSamples[key].lod0()
The type of this is also BlobLoader.  I have a feeling, that 
karcSamples[key].lod0 only returns a function pointer (the 
property function) which is implicitly evaluated, except when I 
use the ._size thing to evaluate a property.

karcSamples[key].lod0()._size
And this finally works, but it's ugly.

Anyone knows how to eliminate that extra () from there?  The 
typeof() is works good for it, but the actual compilation thinks 
it's "void", not the BlobLoader struct reported by typeof(). Only 
the extra () let it compile successfuly.


More information about the Digitalmars-d-learn mailing list