Page 1 of 1

how to use listen stmts

PostPosted: Mon Feb 11, 2008 8:43 am
by miked
Hi Chuck,

You've captured in one place so many of the language features that I've wanted. Thanks! I'm thinking about doing a decent sized project in Cobra, but I have two questions:

1) do you have a time frame as to when you'll have first-class functions?
2) can you post a simple example of a Windows form with a button and a click event handler? I;ve got a form working, but I'm not clear on how to get the listen stmt to work with it.

Thanks.

Re: how to use listen stmts

PostPosted: Mon Feb 11, 2008 11:01 am
by Charles
You're welcome.

Time frame on first-class functions: probably last week of Feb or first week of March. I'd like to have them done by yesterday, but there a few bugs to squash and some source to open.

WinForms example. I'll try to get to this later today, but maybe it would help if I published the existing test case so you can at least see the syntax in a program that executes.

use System.ComponentModel

class Test

var _visited as bool

def main is shared
Test().run

def run
assert not _visited
using c = Component()
listen c.disposed, ref .componentDisposed
assert _visited

_visited = false
using c = Component()
listen c.disposed, ref _componentDisposed
assert _visited

def componentDisposed(sender as Object, args as EventArgs)
_visited = true

def _componentDisposed(sender as Object, args as EventArgs)
_visited = true

Re: how to use listen stmts

PostPosted: Wed Nov 05, 2008 3:32 am
by jonathandavid
Time frame on first-class functions: probably last week of Feb or first week of March. I'd like to have them done by yesterday, but there a few bugs to squash and some source to open.



Hi,

Is this first-class functions already implemented? I browsed the docs but couldn't find any info.

Re: how to use listen stmts

PostPosted: Wed Nov 05, 2008 3:53 am
by Charles
For starters see:

-- How To Pass References to Methods

-- How To Use Win Forms

For storing references to methods in variables, or taking them as parameters, see:

-- Cobra 0.7.4 Release Notes

If you have a Subversion workspace, you can browse test cases under <workspace>\Tests\220-delegates-etc

If you have further questions after reviewing the above material, let us know.

Re: how to use listen stmts

PostPosted: Sat Nov 08, 2008 9:27 am
by jonathandavid
Chuck wrote:For starters see:

-- How To Pass References to Methods

-- How To Use Win Forms

For storing references to methods in variables, or taking them as parameters, see:

-- Cobra 0.7.4 Release Notes

If you have a Subversion workspace, you can browse test cases under <workspace>\Tests\220-delegates-etc

If you have further questions after reviewing the above material, let us know.


Thanks. What about other features of functional programming such as currying, lambdas, closures? Any plans for implementing those?

BTW, I really like what I've seen of Cobra so far. I plan to start a little project using Cobra soon, I'll keep you informed of any bugs or suggestions that pop up.

Re: how to use listen stmts

PostPosted: Sat Nov 08, 2008 2:05 pm
by Charles
I definitely plan on implementing lambdas and closures. Not planning on implementing currying at this time.

Feedback is always appreciated.

Be sure to use Cobra out of the source code repository. There is a handy install-from-workspace script in the Source directory and we have an extensive automated regression test suite, so it tends to be fairly stable.

-Chuck