First of all, kudos to Chuck for these two additions. They will certainly make Cobra a much more modern and productive language.
About lambdas: this is just syntactic sugar for creating a single-line anonymous method, right? What I mean is that your example would be equivalent to:
t = [3, 2, 1]
t.sort(do(a as int, b as int))
return a.compareTo(b)
The compiler should probably emit a warning message ("warning: lambda syntax is the preferred way for declaring single-line anonymous methods", because the lambda way is certainly more readable.
Although the current implementation is nice, I wonder how much work it will be to add parameter type inference. Isn't it just a matter of analyzing the signatures of the potential candidates, and choosing the one that fits (or aborting compilation if none exists)?
I'm asking because this will be sooo much nicer:
t = [3, 2, 1]
t.sort(do(a, b) = a.compareTo(b))
On a related note, I've seen some languages that use an even more streamlined approach to lambdas, through the use of a coupe of special parameter placeholders:
t = [3, 2, 1]
t.sort(_a.compareTo(_b))
I've made up the _a, _b part, other obvious options include $a, $b or _1, _2. I wonder what's your opinion on this approach. Mine is that is allows for more readable code, which is always nice. I don't think it would be hard to implement, we just have to take the whole expression, append "do(_a, _b)" in front of it, and apply the code that deals with regular lambdas.