Cobra 0.3 now works on Novell Mono, adds slicing, adds "for expressions", makes syntactic and semantic refinements, reports more errors at once, eliminates false error chains, and fixes several bugs. Obviously, the best Cobra yet!
Additions / Major Improvements
- Cobra now works on Novell Mono on Mac OS X. It will likely work on any UNIX/posix system running Novell Mono.
- Slicing (as seen in Python). This is the ability to take a range of elements from a sequence by specifying a half-open interval from one index to another. Sequence types include String, List<of>, IList<of>, ArrayList And IList. For example:
- "For expressions" are now supported. These are analagous to Python's "list comprehensions" and also, in relation to upcoming versions of C# and VB.NET, a kind of "LINQ Jr.".
- Parens are no longer required when calling methods without arguments:
- Using base in a method or property implementation now implies an is override or is new for the method—therefore, you can skip these when using base.
- There is a new -files command line option which lets the Cobra source files be specified in a separate text file. Put one filename per line. Lines that are blank or start with pound sign (#) are ignored.
cobra -compile -files=files-to-compile.text
Refinements / Minor Improvements
- Classes, interfaces and structs are now public by default as originally intended.
- The equality operator (==) now returns true for collections such as lists and dictionaries (whether generic or not) if they have the same count and same contents. You would still use is to test for object identity, rather than content equality.
- The new keyword can be used to designate a new method that hides the one that would have been inherited:
- When a method, property or indexer has the same name and type signature as a base member, you must now specify is override or specify is new or use base in the implementation. Otherwise, an error will be reported. This is quite helpful since the former default behavior of is new was often the opposite of what you might want, given that members are virtual by default.
- A catch block can specify a type instead of a variable like so:
- Local variables that are assigned to, but never used, generate a warning. This is great for catching misspellings.
- Improved error message when a method (or property) is missing statements.
- Improved error checking for duplicate classes (formerly had no line numbers).
- Warn if a file is zero bytes in length or comprised of nothing but whitespace.
- Error recovery has improved such that errors in the conditions for if and while statements do not stop error checking from proceeding in their blocks of statements.
- Error recovery improvements for complex expressions.
- False error chains have been eliminated. "Unknown identifier" errors are no longer generated for identifiers whose "defining expression" such as x = someExpr were erroneous themselves. Previously, an error in someExpr would then give an error for x everywhere that x was used.
- AssertException, RequireException and EnsureException all display their info with CobraCore.ToTechString(info) which yields more technical output such as the contents of lists and dictionaries. This makes the exceptions more informative.
- Cobra no longer allows a is b where a and b could never be identical due to their types. This is not only a useful check in general, but catches a mistake C# programmers are likely to make where they use is when they really meant inherits (for example, obj inherits String).
- The Cobra command line now properly handles filenames with spaces.
- Ensure conditions are no longer evaluated if the method they ensure is throwing an exception.
- Redeclaring a local var with a different type now generates a proper error message.
- Can now write List<of List<of Expr>> instead of the former workaround List<of List<of Expr> >
- Lexical errors no longer cause the compiler to choke. Instead they are properly reported with correct line and column number information.
- Calling _foo(1) where _foo is an overloaded method definition now works.
- Overloaded methods that were split across class inheritance no longer confuse the compiler.
- The if(cond, texpr, fexpr) expr now yields the correct type when using nilable types and nil for either or both of the value arguments.
- For loops no longer have to declare new variables. They can now use class vars, parameters and previously declared local vars for their control variables.
- A using statement can now use class vars and previously declared variables.
- Contract conditions now report their correct line number. (Previously, they all reported the line number of the require or ensure keywords.)
- cobra -test SomeLibrary.cobra no longer chokes on interfaces.