Cobra Release 0.7.4
Cobra 0.7.4 adds typed method signatures (aka delegates) and assembly level attributes. Additionally, there are several bugfixes and refinements.
Additions
- Added support for declaring typed method signatures, aka delegates. Creating a method signature creates a type that can be used to pass method references around.
sig BinaryOp(a as int, b as int) as int
# accepting a delegate:
def foo(op as BinaryOp)
x = op(a, b)
# passing a delegate:
.foo(ref .add)
- Added assembly level attributes.
assembly
has AssemblyVersion('1.2.3.4')
has AssemblyDescription('Library for ...')
- Added MustUseResultAttribute which you can use to get help from the compiler when you require that a method's return value be used. In other words, you want a warning when the return value is ignored.
class Something
def computeFoo as int
has MustUseResult
return 42
class Program
def main is shared
s = Something()
s.computeFoo # warning: The result of "computeFoo" should be used in an expression
# such as assignment or passing arguments (as indicated by
# its MustUseResult attribute).
Refinements
- Added -key-file, -key-container and -delay-sign command line options. See "cobra -h" for details.
- The -debug command line option now implies -debugging-types:no.
- The compiler now gives suggestions for unknown method calls (previously only unknown properties and argless method calls triggered suggestions).
- Added "use" suggestion for "using" for the benefit of C# developers.
- Give a specific error message for unexpected indentation:
Expecting a statement instead of extra indentation. One indent is 4 spaces or 1 tab with display width of 4.
Fixes
- Fixed: Cobra sometimes picks the wrong return type when invoking an overloaded method.
- Fixed: Cobra gives a false error message when comparing ints of different sizes.
- Fixed: Cobra cannot directory run programs on Mono on Windows due to quoting with single quotes instead of double.
- Fixed: The command line help for -embed-run-time fails to mention that copying Cobra.Lang.dll is necessary (since it is not registered in the GAC yet).
- Fixed: Primitive types such as 'bool' and 'int' are not type compatible with their backing System struct types such as System.Bool and System.Int32.
- Fixed: Cobra doesn't exclude irrelevant warnings from the C# backend for non-English languages.
- Fixed: Cobra does not detect unused local variables in many cases (which generate warnings).
- Fixed: Starting an argument with an underscore blows up the compiler!