DMD 0.174 release

Chris Nicholson-Sauls ibisbasenji at gmail.com
Thu Nov 16 06:37:58 PST 2006


Jarrett Billingsley wrote:
> "Reiner Pope" <reiner.pope at REMOVE.THIS.gmail.com> wrote in message 
> news:ejg8qd$475$1 at digitaldaemon.com...
> 
>>Jarrett Billingsley wrote:
> 
> 
>>I'm not sure if this is what you want, but here's a cast-free 'call' 
>>function:
>>
>>...code...
> 
> 
> Ah!  That's an alright tradeoff.  I didn't actually know that you could set 
> the .ptr and .funcptr properties of delegates; I thought they were 
> read-only!  Cool. 
> 
> 

I didn't know this either... and it opens some ideas up to me...  Like, perhaps one could 
do the following:

# class Foo {
#   void bar () { ... }
# }
#
# Foo[] list = ... ;
# auto dg = &list[0].bar;
# dg();
# foreach (x; list[1 .. $]) {
#   dg.ptr = x;
#   dg();
# }

Might actually be slightly cheaper than a normal call in some cases, particularly of Foo 
and/or bar() are final.  Will have to test it...

-- Chris Nicholson-Sauls



More information about the Digitalmars-d-announce mailing list