Safer casts

Yigal Chripun yigal100 at gmail.com
Mon May 12 16:48:02 PDT 2008


Dee Girl wrote:
<snip>
maybe I still didn't explain myself properly. I've used the term
"sort-with-delegates" meaning a specific instance of sort when given a
delegate as input. I thought this was clear enough, otherwise I would
have simply said "sort".
before you start sending me assembly code, let's go over it again and
make sure we both understand each other:
you take the sort template, stick in a delegate, mix for five minutes
let is simmer for one more and viola: you got the exact same thing if
you would have written sort as a regular function which receives a
delegate parameter.
the template takes the symbol it receives (the delegate name) and
"embeds" it in the sort instance.
both ways you get:
1) a call to sort
2) a call to the delegate
the only difference is the number of parameters the sort function
receives when called.
the regular sort function can run different delegates at runtime (this
is what you call "dynamic". the template has the call to the specific
delegate embedded so for different delegates you need different sort
instances.



More information about the Digitalmars-d mailing list