Safer casts

Janice Caron caron800 at googlemail.com
Sun May 11 15:47:03 PDT 2008


On 11/05/2008, Yigal Chripun <yigal100 at gmail.com> wrote:
> I don't follow. How can there be only one sort instance?

Because I only instantiated it once - specifically with the delegate
named "compare".

>  the mysort function uses both sorts

No, the mysort function is handed a delegate an input parameter.


> so the code for both needs to be in
> the executable...

The comparison functions need to be in the executable, but not two
separate instantiations of sort.

Why is my last post not clear? You get two instantiations with

    sort!(English)(text);
    sort!(Czech)(text);

because I statically passed in two separate delegates, but you only
get one instantiation with

    sort!(compare)(array)

because I statically passed in only one delegate. That you passed two
into mysort is irrelevant, because that's a runtime thing.



More information about the Digitalmars-d mailing list