Based on the nice iterator concept,
but extending the variable to a pattern:

///
match ?i,?j in list( (1,2), (2,3), (3,4)) do
 println$ i,j;
done

union X = | A of int | B of double;
match A ?i in list (A 1, B 1.2, A 22) do
  println$ i;
done
///

Suggestions on syntax welcome. We could use

        for let ... in ...

instead of match, since "match" doesn't really suggest a loop.
Unfortunately we can't use

        for pattern in ...

unless we change so you have to write:

        for ?i in lst do ...

instead of

        for i in lst do ..

since, in a pattern, a simple name is always a constructor name,
and you have to use a ?x for a variable x.

My next trick is to trash Perl. With something like

        for "(\\w)" in "some words here" do
                println _1;
        done

which will be a typical string search for a regexp.
To use a regular definition one might have to say

        for regdef  group(identifier) in "some words here" do 
                println _1;
        done

It is now becoming the case in Felix that the semantics are
strong enough to do just about anything really nice.. the big
problem is now finding cute syntax.

The "match .. in .. " construction above took all of 5 minutes to 
implement.

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




------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to