On 14/01/2013, at 8:05 PM, Nil Geisweiller wrote: >> >> match ?i,?j,?k in iter3 (3,3,3) do >> println$ i,j,k; >> done >> ; > > That's cool! Although I dislike the ? in front of the matched > variables, but I believe I've read in another thread that the parser > can be improved so that the ? are not required, right?
I hate the ? too. But a plain identifier can't be used easily because we have to distinguish match variables from (union) constructors. In Ocaml this is done with Caml case: constructors start with Upper case letters and variables lower case. I hate that more! It doesn't easily generalise to Unicode. ATS solves the problem as follows: unlike ML and Ocaml there are no constant constructors. you cannot have this: union boolean = | true | false Instead all constructors are like functions: union boolean = | true of unit | faise of unit ; val x = true (); match x with | true () => .. | false () => .. This is a significant simplification to the compiler too, since now all constructors have an argument, a heap of special cases disappear. The parser can now tell the difference between variables and constructors: constructors are applied to something, variables are not. So match x with | f x => where f is a constructor and x is a match variable. Now I hate true () everywhere. But luckily we *already* have the notation: #f // means f () and #true is much more acceptable! It does mean though that: enum X = one, two; var x : X = #one; i.e. you HAVE to write the # everywhere. Otherwise you get a closure wrapper: union X = | A of () | B of int ; var b = B; You probably didn't mean that; here b is a function: var b = fun (j:int) => B j; [Felix automatically generates wrappers] This would happen with A as well. BTW: you will not actually have to write #true. This is because true is recognised by the parser and replaced with its value: case 1 of 2 Of course that will change to (case 1 of 2) () There's another way: ? basically means val. So: match 1,2,3 with | val x, val y, val z => which is of course the same as ?x,?y,?z except we now write "val" instead of ?. The advantage of this is that you could also write | val x, var y, val z => ++y; ... i.e. now you could have mutable match variables as well. Then we have let val x, var y, val z = 1,2,3 in .. as well. Of course instead we could allow ? as a shorthand and then: ?x = 1; would be allowed. You can already write x := 1; as a shorthand for val x = 1;. Cool syntax is hard work! -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122412 _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language