Safer casts

Yigal Chripun yigal100 at gmail.com
Sun May 11 16:24:04 PDT 2008


Janice Caron wrote:
> 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.

OK, I think i understand you now. there is only one sort instance that
calls compare. compare changes at run-time. in that case, I was wrong.
sorry for the confusion.



More information about the Digitalmars-d mailing list