Anonymous delegates and auto
Mike
vertex at gmx.at
Sat May 24 05:36:16 PDT 2008
Hi!
Using delegates and command chaining ... just awesome.
' .sort((ref CTestFloatClass v1, ref CTestFloatClass v2) { return
v1.value < v2.value ? -1 : v1.value == v2.value ? 0 : 1; })
However, is there a reason why DMD can't infer the types of v1 and v2? It
infers the return type from the expression, but it can detect a type
mismatch in the delegate definition, so it has the information to make
this work:
' .sort((auto v1, auto v2) { return v1.value < v2.value ? -1 : v1.value
== v2.value ? 0 : 1; })
And, considering how foreach works, this:
' .sort((v1, v2) { return v1.value < v2.value ? -1 : v1.value ==
v2.value ? 0 : 1; })
Any reason why this wouldn't work (probable parsing problems aside)?
-Mike
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list