Is there a way to create compile-time delegates?

Don nospam at nospam.com
Wed Jul 21 21:11:59 PDT 2010


Simen kjaeraas wrote:
> Sean Kelly <sean at invisibleduck.org> wrote:
> 
>> Don Wrote:
>>
>>> Philippe Sigaud wrote:
>>> > On Mon, Jul 19, 2010 at 22:01, torhu <no at spam.invalid> wrote:
>>> >
>>> >
>>> >
>>> >     I wasn't able to make it work.
>>> >
>>> >
>>> > Me too :(
>>> >
>>> >
>>> >     The compiler probably sees delegates as something that just 
>>> can't be
>>> >     created at compile time, since no runtime contexts exist then.
>>> >      Which is reasonable.
>>> >
>>> >
>>> > Can you initialize pointers in general, at compile-time?
>>>
>>> You cannot initialize a pointer to runtime-allocated data at
>>> compile-time, and will never be able to. This particular example cannot
>>> ever work.
>>
>> You can get pretty close by using structs with opCall defined though.
> 
> Not if the function I got only takes delegates, and needs to only take
> delegates.
> 
Eventually, it should be possible to have a compile-time delegate which 
points to an immutable static variable. Doesn't work at the moment, though.


More information about the Digitalmars-d-learn mailing list