struct opCall makes a nan

Bill Baxter dnewsgroup at billbaxter.com
Sun Mar 23 19:00:40 PDT 2008


dominik wrote:
> it works now, thanks!

Great.  Did you need to add an explicit call to it?

> 
> "Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message 
> news:fs6rdm$23j4$1 at digitalmars.com...
>> Should be "static plane opCall".
> 
> could you please explain why it should be static? 

Because you don't have any instance at the time you're calling it. 
Maybe you're thinking of it like the equivalent of a constructor.  It's 
not.  It's just a hack that's been somewhat canonicalized by the 
language.  It's just a factory function*.  You could call it "create" 
and invoke it as "plane.create()".  You could call it anything you want, 
but it needs to be static.  Or you could move it outside the class and 
call it "createPlane".


[*] Except that D will automatically call a single-argument static 
opCall if an initializer matches the opCall's argument.  So if for some 
reason you had
    static plane opCall(string x) { ... }
and did
    plane foo = "hi there";
that would call your static opCall(string) method.  Otherwise static 
opCall is just an ordinary static method.

--bb


More information about the Digitalmars-d-learn mailing list