Tim Jansen's blog


2004/12/19
Progress...
Everything is going well and I am confident that I will finish the specification of the language this year. Right now I rather work on the spec than blog about the changes, as there are quite many. But here are a few examples of the new syntax. Method Syntax I have changed the message syntax from C/Java-style to Pascal-like signatures. This solved most of my problems with the delegate syntax and is more logical anyway. Why should the name of a method be between the output and the input types? Here are two ways of writing a method with the new syntax:
add(int a, int b): int
        return a + b

add(int a, int b): (int r)
        r = a + b

Delegates Now the syntax of a delegate type becomes easy, just use the 'delegate' keyword instead of the method name. I have abandoned my original idea which required giving delegates names - it's often hardly possible to find a good name for a delegate. But if the programmer wants it, she is free to create an alias for a delegate, which does exactly the same.
delegate(int,int):int myDelegate = add
Closures I have two closure variants, one for embedded expressions and one for multiline closures. Both can be declared either without argument specification (for closures that use up to one argument) or with full argument specification:
// Embedded closure, full prototype
delegate(int,int):int myDelegate1 = closure(int x,int y):int {x + y}

// Multiline closure, full prototype
delegate(int,int):int myDelegate2 = closure(int x,int y):int {{
        return x + y
}}

// Embedded closure, simplified ('it' is a special variable 
// that contains the first argument)
delegate(int):int myDelegate3 = { it * it }

// Multiline closure, simplified ('it' is a special variable 
// that contains the first argument)
delegate(int):int myDelegate3 = {{
         return it * it 
}}
Generics The generics syntax looks a bit like a mixture of Java's and C++'s, but it works more like Java's. Both classes and methods can contain generic variables. Let's start with a class:
class Stack<Object T>
        private Array<T> mArray

        push(T obj)
                // ...

        pop(): T
                // ...
end
Here's a method:
add<Number T>(T a, T b): T
        return a + b
and here a delegate and a closure:
delegate<Number T>(T,T):T myGenericDelegate = closure<Number T>(T a,T b):T { a + b } 
Events And finally the event syntax, which is exactly the same as the syntax that I favored a year ago, just with the new method signature:
        event pointerClicked(int x, int y, int button)



 

This blog is my dumping ground for thoughts and ideas about Eek. Someday Eek will be a programming language and system, somewhat comparable to Java in scope. It is my attempt to bring sanity to the world of computing.
At least I hope so. Right now it is far from being finished and I can't guarantee that it ever will be. I am still working on the specification, but I won't release anything before I got my first prototype running. The world does not need more vapourware and unusable beta-software. All publicly available information about Eek is contained in this blog. You can find the latest summary here.
This page is powered by Blogger. Isn't yours? Creative Commons License
This work is licensed under a Creative Commons License.