C-omega on MS


Source: http://research.microsoft.com/Comega/


C-omega, is “a research language intended to foster new thoughts and ideas about programming languages, Cw (pronounced C-omega) is a combination of what used to be X#/Xen and Polyphonic C#. It’s an interesting combination of new ideas, and is most certainly worth a look.”


As I’ve said before, languages like Xen/X#, Polyphonic C#, Cw and many others are research languages and not a replacement of C#.

Comments (4)

  1. Ron Buckton says:

    Polyphonic C# looks interesting but it doesnt look like it makes anything simpler. IMHO an "async" keyword would be a nice addition but i would imagine its functionality to do something like:

    class Foo

    {

    public async int Add(int a, int b)

    {

    Thread.Sleep(1000);

    return a + b;

    }

    }

    which would generate some kind of pseudocode like:

    class Foo

    {

    /// <summary>

    /// Compiler Generated IAsyncResult

    /// </summary>

    private class __AddAsyncResult : IAsyncResult

    {

    private WaitHandle _waitHandle ;

    private object _state ;

    private bool _completedSynchronously;

    private bool _isCompleted;

    private Exception _asyncException;

    private int _returnValue;

    private Thread _thread;

    public __AddAsyncResult(object state)

    {

    _waitHandle = new AutoResetEvent(false);

    _state = state;

    _thread = new Thread(new ParameterizedThreadStart(Work));

    }

    object IAsyncResult.AsyncState

    {

    get { return _state ; }

    }

    WaitHandle IAsyncResult.AsyncWaitHandle

    {

    get { return _waitHandle ; }

    }

    bool IAsyncResult.CompletedSynchronously

    {

    get { return _completedSynchronously; }

    }

    bool IAsyncResult.IsCompleted

    {

    get { return _isCompleted; }

    }

    public Exception AsyncException

    {

    get { return _asyncException; }

    set { _asyncException = value; }

    }

    public int ReturnValue

    {

    get { return _returnValue; }

    set { _returnValue = value; }

    }

    private void Work(object arg)

    {

    object[] args = (object[])arg;

    try

    {

    _returnValue = Add((int)args[0], (int)args[1]);

    }

    catch (Exception ex)

    {

    _asyncException = ex;

    }

    finally

    {

    _isCompleted = true;

    }

    }

    private int Add(int a, int b)

    {

    Thread.Sleep(1000);

    return a + b;

    }

    public void AsyncAdd(int a, int b)

    {

    object[] args = new object[2];

    args[0] = a;

    args[1] = b;

    _thread.Start(args);

    }

    public bool CompletedSynchronously

    {

    get { return _completedSynchronously; }

    set { _completedSynchronously = value; }

    }

    }

    /// <summary>

    /// Compiler Generated Asynchronous Begin method

    /// </summary>

    public IAsyncResult BeginAdd(int a, int b)

    {

    __AddAsyncResult aa = new __AddAsync( null );

    // Starts the Add operation asynchronously in either a new thread or a thread pool.

    aa.AsyncAdd( a, b );

    return aa;

    }

    /// <summary>

    /// Compiler Generated Asynchronus End method

    /// </summary>

    /// <param name="ar"></param>

    /// <returns></returns>

    public int EndAdd(IAsyncResult ar)

    {

    if(ar == null)

    throw new ArgumentNullException("ar");

    if(!(ar is __AddAsyncResult))

    throw new ArgumentException("some error", "ar");

    __AddAsyncResult aa = (__AddAsyncResult)ar;

    aa.WaitHandle.WaitOne();

    if(aa.AsyncException)

    throw aa.AsyncException;

    return aa.ReturnValue;

    }

    /// <summary>

    /// Synchronous Method

    /// </summary>

    /// <param name="a"></param>

    /// <param name="b"></param>

    /// <returns></returns>

    public int Add(int a, int b)

    {

    __AddAsyncResult aa = BeginAdd(a, b) as __AddAsyncResult;

    aa.CompletedSynchronously = true;

    return EndAdd( aa );

    }

    }

    any thoughts?

  2. Ron Buckton says:

    I know there are some errors (such as not properly waiting for the IsComplete…) :/

  3. nal says:

    http://www.doc.ic.ac.uk/~ajf/Teaching/Projects/DistProjects.html

    Has a recently published Masters thesis exploring chords and chorded programming, including building "a chorded compiler for Java".