I have code like this:

        var x1 = test1;
        if x1 do
                ...
        else
                var x2 = test2;
                if x2  do
                        ...
                else
                        var x3 = test3;
                        if x3 do 


The "elif" clause normally relieves this nesting problem,
but doesn't work when you have to compute something
prior to the next test. So I'm trying this:

        if x do
                ...
        otherwise

        blah;
        if x2 do 
                ..
        otherwise

"otherwise" is the same as "else" except scope extends to the end of
the enclosing scope. Another way to do this is make "else" do what
"otherwise" does and then add do/done:

        do 
                if x do ..
                else ..
        done

This is the Ocaml syntax (they use begin/end and if/then).
Gets rid if "elif" since you can now write "else if".

Ocaml generally open-scopes trailers like this:
let .. in, match .. with, if ..else all work that way (but
for loops don't).

This makes some code more compact, but editing is a pain
because you have to "back up" to put the "do/begin" at the top
of a scope when you terminate it with "done/end", i.e. the
Ocaml method is fragile.

I note in passing ML uses let .. in .. endlet (i forget the actual
terminator).

C is similar:

        if (c) x;
        if (x) { x; y; }

Fragile. But whilst Felix 
        
        if x do x; done

is robust it also leads to a lot of ugly "done"s at the end
of nested blocks .. almost as bad as Lisp.


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to