--- Comment #7 from Manu <turkey...@gmail.com> 2012-04-20 17:16:54 PDT ---
(In reply to comment #5)
> (In reply to comment #3)
> > As I saw it, this is just a single function pointer (surely that is strictly
> > defined by the 'function' keyword?) in a struct.
> It isn't a function pointer. Non-static member methods are never a simple
> function pointer, they always require a 'this' pointer as well, as they are
> delegates. This is not like C++ member function pointers.
extern(C) void function( const char* format, ... ) outputDebug; <- this is a
function pointer. It's not a method, or a delegate. I have no idea why you're
introducing methods and delegates into the conversation. But it doesn't matter,
it's irrelevant to the problem here...
> > AliasTheInt!( thing.x )(); // this is the problem
> Right. It's a problem because thing.x is being passed as an *alias* parameter.
> An alias must be symbol, not a computation on a symbol. thing.x is
> equivalent to:
> *(&thing + x.offsetof)
> which is not a symbol.
Oooohkay, so now we get to the bottom of it.
Right, well I didn't realise that restriction. I just assumed any statically
addressable variable was alias-able.
So this is a feature request then, not a bug.
There's still technically no reason it shouldn't work, it's just not quite how
alias is written?
How much trouble would it be to extend 'alias' to include an offset value?
This restriction makes it very difficult to drill down into structures via
recursive enumeration. The workaround I've had to use is to use strings instead
of aliases that can mixin an absolute reference, but it's really untidy, and
again, messes with the editor a lot (syntax hilighting, auto-complete, etc).
It also requires mixin(a) everywhere, and there are lots of cases where mixin()
is invalid in the middle of an expression. This requires a further workaround
to build the whole expression into a string and mix the whole thing in.
I wonder if you could use lowering here to produce the same result via lowered
mixin? Although it sounds much cleaner to simply add an offset to aliases.
Another alternative could be to just invent the appropriate symbol when a
reference like this appears. Symbol names follow the d scoping patterns right?
In this case, the symbol would just be my.module.thing.x (or with whatever
mangling happens to appear in D symbols).
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------