The Cobra Programming Language Version 0.1.1 Release Notes 2006-06-04 ------------------------------------------------------------------------------ See also: Cobra\ReadMe.text Cobra\Docs\License.text Cobra\Docs\Introduction.text http://CobraLang.com/ In this release: == Additions == * Added constraints for generic parameters: class Inventory where TItem must be Item # <-- constraint def add(item as TItem) print item.code # <-- using specific property of Item class Item get code as String return '00329023' * Added the `using` statement: using VAR = EXPRESSION STATEMENTS using sr = File.openText(fileName) while true line = sr.readLine() if line is nil break print 'len=[line.length] "[line.trim()]"' The IDisposable.dispose() method will be invoked on the given variable at the end of execution. This is useful for ensuring that external resources such as open files and database connections are closed. * Added `expect` statement to aid with unit testing. Like the `using` statement, it takes a block of code. It will raise an ExpectException if the block of code does not raise an exception, or raises one that does not match what was expected. You should write `expect` statements when creating tests for methods that are known to throw exceptions under certain circumstances. expect IndexException t = [1, 2] x = t[2] * Added --test command line option to execute the unit tests found in a library. This saves you from having to temporarily add a main() method to accomplish this and then remove it to use the library as a library. Also, it provides progress of the tests as they execute. cobra --test MyLibrary * Added FallThroughException(value) for use at the end of if-else ladders or methods. if x.foo print 'foo' else if x.bar print 'bar' else throw FallThroughException(x) * Added new HowTo programs: ReadAndWriteFiles MakeAnIfElseLadder MakeABranchStatement DeclareConstructors DeclareAndUseVariableNumberOfArgs CheckInheritanceAndImplementation == Changes and Minor Improvements == * Changed the syntax for declaring generics from: class Foo of Bar to: class Foo The new syntax is really an existing syntax--it's the same one used when naming a generic type in an `inherits` clause and code: t = List() == New and Improved Warnings and Error Checks == * The compiler emits a warning for the likely mistake of "someArg = _someClassVar": "Setting a parameter to a class variable is often a mistake. You may want to reverse the assignment." * Added error check: Missing return statement for method "NAME" which returns TYPE. * Added error check: Cannot inherit an interface. Use "implements" instead. * Added error check: Cannot implement a class. Use "inherits" instead. * Added error check: Emit an error when one side of a binary operator is a method call that doesn't return anything. * Improved or new error messages regarding case and underscores. Now with suggestions: Class variables must start with an underscore to distinguish them from other types of identifiers. Try "_NAME". Class variables must start with lowercase letters (after the underscore(s)) to distinguish them from other types of identifiers. Try "_foo". Local variable/parameter declarations cannot start with an underscore. Those are reserved for class variables. Try "foo". Local variable/parameter declarations must start with a lowercase letter to distinguish them from other types of identifiers. Try "foo". A class variable must be made of more than underscores. Try "_x" or "_1". == Fixes == * Fixed: \0 in string literals does not work. * Fixed: Qualified types cause compilation problems if the containing namespace is not implicitly or explicitly used. * Fixed: The non-generic IEnumerable type is not compatible with `for` loops. ------------------------------------------------------------------------------