What's the opinion of 'getting rid' of semicolons?
The effect will basically be: you can leave
semicolons off the end of statements, provided
the next statement starts with a keyword, OR,
the statement has an explicit terminator:
val x = 1
var y = 2;
x = y;
f x
fun g(){}
whilst x < y do
var x = 1
val y = 2;
x = y
done
if x > y do f x done
In effect, the ; is like a leadin keyword:
val x = 1
var y = 2
; x = y
; f x
fun g(){}
except you don't need it at the start.
Semicolons can still be used of course.
Although this isn't "layout" based parsing,
it may appeal to some people. A side-effect is
reduced ability to catch errors, since the extra
redundancy of the ; helps with that.
Some syntax changes will be required, for example
fun f()="" require fred
would now be ambiguous, since it could mean either
fun f()="" require fred; // or
fun f()=""; require fred;
I'm thinking
we require fred
for the global version :)
A couple of other places will be affected, not sure how:
the most worrying is | which somehow becomes ambiguous.
I also found the user RD parser screwed up: it relies
on an explicit terminator: at least for expressions
it 'cheats' and 'pushes back' an overshoot into
the lexer when it reads one token too far.
There is a slightly different way to view this.
When you write:
x = 1; f x; endl; y = 2
this can be viewed as a *single* statement,
consisting of expressions combined with the
n-ary chained ; operator (effectively left
associative binary operator).
This is a kind of weird expression of type:
void * void -> void
where 'void' really means a command with side effects.
This would allow | to be used the same way:
x = 1 | y = 2 | z = 3
for parallel operations: now ; means sequential, and |
means parallel. Somewhat unfortunately for that idea in
match x with
| a => b
| ..
the actual operation is strictly sequential.
-------------------------------------------
BTW, I don't like match much. I think Jay's case
is cleaner:
case a => b | c => d endcase x
means the same: match is a closed term, so to use
it as a function it has to be lambda abstracted:
(fun:t1->t2 = | a=> b | c => d) x
and even that is a shortform. The main advantage
of match is that the argument type doesn't have
to be named.
Perl actually as
pat ~= arg
for a match .. interesting. (Hmm or is it arg ~= pat .. ?)
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language