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

Postby Charles » Sun Nov 30, 2008 6:31 pm

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, value
for 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).

-- Updated -about with more URLs for license, support, etc.

-- 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 Point sample.

-- 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: 2515
Location: Los Angeles, CA

Re: Cobra November 2008 Update

Postby helium » Mon Dec 01, 2008 4:22 am

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

Postby relez » Tue Dec 02, 2008 1:33 pm

Great! This is almost a 0.9 verson....
relez
 
Posts: 69

Re: Cobra November 2008 Update

Postby gauthier » Sun Dec 07, 2008 10:12 pm

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

Postby Charles » Mon Dec 08, 2008 12:01 am

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.

See also <workspace>\Tests\240-generics\300-declare-generic-classes\602-instantiate-generic-arg.cobra
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 106 guests

cron