metaocaml

Another limitation of F# quotations?

点点圈 提交于 2019-12-09 16:28:11
问题 Earlier today I encountered a limitation of F# quotations, and asked a question about it here: F# quotations: variable may escape scope Now, I may have encountered another limitation when converting examples appearing in http://www.cs.rice.edu/~taha/publications/journal/dspg04a.pdf from MetaOcaml to F#. This time I've this MetaOcaml snippet: let rec peval2 p env fenv= match p with Program ([],e) -> eval2 e env fenv | Program (Declaration (s1,s2,e1)::tl,e) -> .<let rec f x = .~(eval2 e1 (ext

F# quotations: variable may escape scope

喜你入骨 提交于 2019-12-06 04:41:31
问题 I have this bit of code: let rec h n z = if n = 0 then z else <@ (fun x -> %(h (n - 1) <@ x + %z @>)) n @> converted from a MetaOcaml example in http://www.cs.rice.edu/~taha/publications/journal/dspg04a.pdf In the paper there is explained that the above example will yield the following with the parameters 3 and .<1>. (in MetaOcaml notation): .<(fun x_1 -> (fun x_2 -> (fun x_3 -> x_3 + (x_2 + (x_1 + 1))) 1) 2) 3>. As you can see the x ´s gets replaced by x_1 , x_2 etc. because the x would

F# quotations: variable may escape scope

浪尽此生 提交于 2019-12-04 08:23:52
I have this bit of code: let rec h n z = if n = 0 then z else <@ (fun x -> %(h (n - 1) <@ x + %z @>)) n @> converted from a MetaOcaml example in http://www.cs.rice.edu/~taha/publications/journal/dspg04a.pdf In the paper there is explained that the above example will yield the following with the parameters 3 and .<1>. (in MetaOcaml notation): .<(fun x_1 -> (fun x_2 -> (fun x_3 -> x_3 + (x_2 + (x_1 + 1))) 1) 2) 3>. As you can see the x ´s gets replaced by x_1 , x_2 etc. because the x would otherwise only refer to the x in the innermost fun . But in F# this isn't allowed. I get the compile-time

Another limitation of F# quotations?

旧街凉风 提交于 2019-12-04 03:27:17
Earlier today I encountered a limitation of F# quotations, and asked a question about it here: F# quotations: variable may escape scope Now, I may have encountered another limitation when converting examples appearing in http://www.cs.rice.edu/~taha/publications/journal/dspg04a.pdf from MetaOcaml to F#. This time I've this MetaOcaml snippet: let rec peval2 p env fenv= match p with Program ([],e) -> eval2 e env fenv | Program (Declaration (s1,s2,e1)::tl,e) -> .<let rec f x = .~(eval2 e1 (ext env s2 .<x>.) (ext fenv s1 .<f>.)) in .~(peval2 (Program(tl,e)) env (ext fenv s1 .<f>.))>. and I