|
Archives
D Programming
digitalmars.Ddigitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger D.gnu D C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - array of functions
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?
Here's a stripped down example:
protected Object function(int)[] lookup = [
&func
];
protected Object func(int)
{
return null;
}
Jun 04 2009
On Thu, Jun 4, 2009 at 12:42 PM, Trass3r <mrmocool 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? Jun 04 2009
Jarrett Billingsley schrieb:On Thu, Jun 4, 2009 at 12:42 PM, Trass3r <mrmocool 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? Jun 04 2009
Jarrett Billingsley wroteIt can't evaluate &func at compile-time because there is no way to create a delegate at compile-time. Jun 05 2009
|