array of functions

Trass3r mrmocool at gmx.de
Thu Jun 4 16:15:54 PDT 2009


Jarrett Billingsley schrieb:
> On Thu, Jun 4, 2009 at 12:42 PM, Trass3r <mrmocool at gmx.de> wrote:
>> I tried to use a function lookup table to quickly access a particular one.
>> But the compiler (dmd1) complains about
>> Error: non-constant expression & func
>>
>> I guess because it's used inside a class since &func is of type function,
>> not delegate?
> 
> You've got it the other way around.  If func is an instance method
> (non-static method) of a class, &func is a delegate, not a function.
> 

I know, but if I change that array to delegates, dmd complains:
Error: cannot implicitly convert expression (&func) of type Object 
function(int) to Object delegate(int)


> It can't evaluate &func at compile-time because there is no way to
> create a delegate at compile-time.
 >

Yeah, gotta use a different approach.


More information about the Digitalmars-d-learn mailing list