Forums

## Cobra November 2008 Update

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

### Cobra November 2008 Update

This is a new update for November, covering improvements since the last update in October.

There is a new HowToInstallFromSource wiki page covering the ease and benefits of using Cobra from the source repository, and how to do it.

The following improvements are due to patches and feedback from the community as well as my own efforts. Thanks to all contributors!

Language

-- Added anonymous methods, also known as closures. Discussed here.

-- Added streams to the language. Discussed here.

-- Added generic constraints on generic methods. See Tests/240-generics/400-generic-methods/130-generic-method-constraints.cobra

-- Added a shortcut syntax for declaring a property and its backing variable in one line.
class X    get x from var as int    # is a short cut for these two lines:    var _x as int    get x from var    # the general form of the shortcut above is:    get <name> from var as <type>        # the fully general form is:    (get|pro|set) <name> from (var|<var-name>) as <type>

-- Added storage type specification for enums. "enum State of uint8"

-- Add support for multitarget assignment in for statements:
for key, value in aDictionary    trace key, valuefor a, b in [[1, 2], [3, 4]]    print a + b

-- Added support for one-line doc strings.
class X    def foo        """ Foo is as foo does. """        pass

Command Line

-- Added command line option -correct-case (or -cc) to change the case of types to the correct cases in situations that are not ambiguous. For example, "list<of int>" will be rewritten as "List<of int>" rather than producing an error. If you can configure your editor to automatically reload modified files then this feature can be quite nice.

-- Added "-out:" command line option to control the name of the resulting executable or library.

-- Support file paths with both backslash (foo\bar.cobra) and forward slash (foo/bar.cobra) regardless of platform.

-- Make the -files: option "relative" meaning that the paths inside that file are relative to that file (instead of say, the current working directory).

-- The default behavior for invoking the Cobra command line with no args is now -about rather than -help.

-- Better error messages regarding invalid option choices.

Misc

-- Made various improvements to "install-from-workspace" based on user feedback and patches.

-- Added new "line endings" program which is useful if you work on Mac, Windows and Windows+cygwin. Look under cobra-workspace/Supplements/le.cobra.

-- Updated and added various wiki pages.

-- Fixed 15 bugs.

-- Improved 5 error messages.

The next update will be next month, towards the end of December, but you can always keep up to date by browsing through the discussion forums.

I hope you'll try out the very latest Cobra!

Best regards,

Chuck
Charles

Posts: 2514
Location: Los Angeles, CA

### Re: Cobra November 2008 Update

Last edited by helium on Tue Dec 02, 2008 10:54 am, edited 1 time in total.
helium

Posts: 14

### Re: Cobra November 2008 Update

Great! This is almost a 0.9 verson....
relez

Posts: 69

### Re: Cobra November 2008 Update

the generic constraint test seems bogus: it doesn't call or assert over swapIfGreater method

Also I would like to know how to constraint for new() and declare multiple constraints (for multiple type parameters, and multiple constraints over a single type parameter)

Thanks
gauthier

Posts: 116

### Re: Cobra November 2008 Update

You're right the test case does not invoke that method. Although it *does* compile, load and run with no complaints from C# or .NET. If the constraint did not exist in the generated code, then the .compareTo invocation would have choked the backend compilation since System.Object has no such method.

Use the keyword "callable" for types on which you want to create instances via calling:
T()T(i, j)

For multiple constraints, separate them with commas.