Some ideas behind efene
For some it may be something small but I consider this two features to be interesting on efene, I think that both may help in creating small domain specific languages that may make easier to code.
Or maybe It’s just me :P
The first one is the posibility to write function arguments without usign a ‘,’ this looks like the following.
draw = fn (dot at X Y) {
io.format("paint a dot at ~p, ~p~n", [X, Y])
}
draw = fn (line from X1 Y1 to X2 Y2) {
io.format("paint a line from ~p, ~p to ~p, ~p~n", [X1, Y1, X2, Y2])
} (square from X1 Y1 to X2 Y2) {
io.format("paint a square from ~p, ~p to ~p, ~p~n", [X1, Y1, X2, Y2])
}
run = fn () {
draw(dot at 10 20)
draw(line from 10 20 to 20 20)
draw(square from 10 20 to 20 20)
}
See how the atoms and the pattern matching allows us to write pretty readable code that is also self documenting
If you are reading code that says draw(dot at 10 20) can you imagine what it does? :P
Imagine you read a line that says open(File to write in binary mode), it would be easier to understand what it does. Some examples may seem extreme but I think that modeling the domain with a DSL makes it easier to code (think on jquery and the DSL it uses to select stuff on the DOM).
The other thing I think could be useful is the ability to write closures without to much typing:
If = fn (true then OnTrue otherwise _OnFalse) {
OnTrue()
} (_ then _OnTrue otherwise OnFalse) {
OnFalse()
}
# let's use it
If(5 > 4 then { Print("5>4") } otherwise {Print("5>4 isn't true")})
# more formated
If(5 > 4 then {
Print("5>4 again")
} otherwise {
Print("5>4 isn't true")
})
Except for the fact that I had to use otherwise to avoid using the else reserved word it looks pretty good.
I would like to hear opinions and ideas about this and stuff about efene, it’s a new project that needs polishing, your help will be apreciated.