Added new statement:

with 
        private-defins
do
        public-defns
done

The definitions in private-defns are made localised to the public-defns.
For example:

var x = 99;
with
        var x = 2;
do
        var y = x;
done
println x,y;

prints (99,2)

This is necessary in cases like:

        var re = RE2 "some-regex";
        fun f(x:string) => Match (re, ... x ... );

where we want re to be compiled once, so it cannot be put in f,
but the way it is written above re is in scope where f is, whereas it's
intended to be private to f. The solution is:

        with 
                var re = RE2 "some-regex";
        do
                fun f(x:string) => Match (re, .. x .. );
        done

The implementation is 

        class dymmy {
                private pdef1; private pdef2; ...
                public-defns
        }
        inherit dymmy;

where pdef1, pdef2, etc are the private defns.


As an artefact of this implementation private definitions in public-defns
won't be "exported" to the surrounding scope either. It's tempting to define

        do .. done

as "with ; do .. done" however whilst this makes sense, it will not be the same
as a "do done" elsewhere, for example in:

var a = 1;
while a < 3 do
  private var b = a;
  println$ a;
  ++a;
done
println$ b;

it all works: b is in scope outside the loop. (maybe it shouldn't be!)

--
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