<div class="gmail_quote"><div>Greetings</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Sure, this does not solve the original problem, if it was really an issue.<br>
@d coder: do you have an example where runtime changing of the comparison function<br>
behavior would be required?<br>
<div class="im"><br></div></blockquote><div><br></div><div>While I do, I am sure there are alternative ways to program to avoid needing those.</div><div><br></div><div>But I think there is a bigger usability issue in what I mentioned. There would be a good number of coders wanting to instantiate BinaryHeap!(SomeContainer, SomeComparator) as a member of another class. I agree that more often it would be the case where SomeComparator does not depend on a state variable. But even then, D does not allow me to provide any function/delegate literal for SomeComparator.</div>
<div><br></div><div>So for example, even this is deemed illegal:</div><div><br></div><div><div>class Foo {</div><div> BinaryHeap!(uint[], (a, b) {return a > b;}) heap;</div><div> // ..</div><div>}</div></div><div><br>
</div><div>To a casual programmer, this would be unacceptable, making BinaryHeap and other such structures too problematic to use. Even when you explicitly specify the delegate literal as a "function":</div><div>
<br></div><div><div>class Foo {</div><div> BinaryHeap!(uint[], function (a, b) {return a > b;}) heap;</div><div> // ..</div><div>}</div></div><div><br></div><div>You get another Error: this for __funcliteral1 needs to be type Foo not type BinaryHeap!(uint[],__funcliteral1)</div>
<div><br></div><div>Regards</div><div>- Puneet</div></div>