Is it possible to use an UDA to generate a struct inside a class ?
Basile Burg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 1 14:49:38 PST 2015
On Thursday, 1 January 2015 at 21:15:27 UTC, Ali Çehreli wrote:
> On 01/01/2015 09:35 AM, Basile Burg wrote:
>
> > On Tuesday, 30 December 2014 at 19:18:41 UTC, Basile Burg
> wrote:
>
> > an ICE (every
> > compiler crash is an ICE right ?),
>
> Yes, the compiler should never crash but produce an error
> message. Please report it preferably with a reduced code sample:
The report is filed. I was not sure of its validity or if it
could be a dup.
-----------------
> You realize, all of those foreach'es are processed at
> compile-time for code generation. There will be no 'o' at run
> time; so its address cannot be used.
Instead, Can I get the *relative offset* of a particular member
at compile-time ?
Then at run-time I could easily define the delegate, eg:
// the AA or some arrays filled at compile-time
ptrdiff_t[string] gettersOffset;
ptrdiff_t[string] settersOffset;
// a delegate, set at run-time, for example in this().
myDelegate.funcptr = gettersOffset["propIdentifier"];
myDelegate.ptr = cast(void*) this;
If so then the problem is solved...even if other problems could
appends, for example if the methods are final, if they are
inlined...
Actually I'd be surprised that nobody has already designed
something similar for properties (kind of "published" attribute
as defined in Pascal-like languages.)
More information about the Digitalmars-d-learn
mailing list