no property 'opCall' for type ... what am I doing wrong?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sat May 5 02:12:57 PDT 2007


Daniel Keep wrote:
> 
> Frits van Bommel wrote:
>> Daniel Keep wrote:
>>> Just keep in mind that you can't take the address of a function
>>> argument, so if you do this inside a function, you have to make a copy
>>> first.
>> I'm surprised by this statement, and can't find a mention of it in the
>> spec.
>> Do you have a reference for it?
> 
> I don't know if it's in the spec (I can't remember ever running across
> it), but I know it doesn't work.
> 
> The problem is that the D calling convention allows for up to one
> argument to be passed using registers, which don't *have* an address, so
> taking the address of them doesn't always make sense.

DMD automatically copies a register-argument to a local variable on the 
stack if the address is required. As does my GDC, it seems...

> In any case, I know the compiler has barfed every time I've tried to do
> it...

It's always worked fine for me.

For instance, the following works, whether I'm using DMD or GDC:
---
import std.stdio;

void bar(int* x) {
         assert(*x == 42);
         writefln("*%s = %s", x, *x);
}

void foo(int x) {
         bar(&x);
}

void main() {
         foo(42);
}
---
(DMD 1.014, GDC 0.23/amd64)


More information about the Digitalmars-d-learn mailing list