Cobra Release 0.7.1
Cobra 0.7.1 adds struct declarations, improves run-time performance, makes minor refinements and fixes a handful of bugs.
Language Improvements
Structs
Cobra supports structs now:
For Expressions
Cobra allows for x in y where x > 0 ... in other words, you can skip the final get x in the presence of where ....
Of course, you'll still use get when transforming the value:
Minor
Added any as a reserved word in anticipation of an any <sequence> operator that returns true if any element in the sequence is true. The word all, which could be used in a similar fashion (but returning true if all elements are true), was already reserved.
Miscellaneous
Contract Code Generation
Recall that Cobra supports contracts like so:
Now there is a new "-contracts:..." command line option with choices: none, inline or methods. The "inline" choice is the default which results in a performance boost over the previous version of Cobra. A call to an empty method is up to 150 times faster than before. More realistic effects on actual applications range from 0% to 20%.
The "methods" options may be useful when splitting projects across libraries.
Here is an example from the command line:
cobra -contracts:none myprog.cobra
Pex
I met Peli de Halleux of the Pex project at the Lang.NET 2008 Symposium where he demonstrated the ability of Pex to automatically find errors in code! We put a Cobra sample through it and bugs in the methods that were due to weaknesses in the contracts. It turns out that Pex can work with preconditions which are a built-in feature in Cobra.
Let's hope Pex is available for general consumption soon.
Library
There are some new properties and methods in CobraCore. The most notable is runCobraExe which makes invoking "cobra.exe" from your own programs easy.
Fixes
- Fixed: For the expression x implements Y, Cobra does not always give the warnings "will always be of type" or "will never be of type" when it should.
- Fixed: Using nilable types with out parameters causes false error messages.
- Fixed: Using out on non-nil reference type arguments causes an error in code generation.
- Fixed: Using out args with -dst causes bad code generation.
- Fixed: Invoking Cobra on a directory gives an unhandled exception.
- Fixed: Cannot make qualified types nilable (?).