Delightful Function Syntax
I've been heavily debating the syntax of the language. Here are some ideas I've had...
First, functions are important, how should they look?
To be honest, I like how Ada does it.
function Count_Letters(Item1, Item2: String) return Natural is Count : Natural := 0; begin ... return Count; end Count_Letters;
Of course in our case, indentation declares the scope. What about this?
count_letters takes string item1, item2 returns int: int count = 0 ... return count
or a more Haskellian approach:
count_letters: string item1, item2 -> int int count = 0 ... return count
And I like calling functions in Haskell. Just use a space! Also, functions have precedence, so you can do things like:
max 5 2 * 4 -- returns 20
Let me know what you think!
Edit: I ended up with some of each. This is still in flux though, so feel free to leave comments.
function add(int a, b -> int): return a + b class C: method subtract(T a, b -> T): return a - b procedure main: int c = add(1, 2) int d = C.subtract(2, 3)
I kept parentheses around function calls because the spaces don't make it clear what is inside the function and what is not. Also, I'm trying to stay just somewhat faithful to Python/D syntax. See post on doing too much for more details.