Hi, all:<br><br> some issues around the redex<br><br>the code snippet:<br><br>(module test mzscheme<br> (require (planet "reduction-semantics.ss" ("robby" "redex.plt" 3)))<br> (define basic-grammar
<br> (language<br> (e x (e e) ("lam" x e))<br> (x variable-not-otherwise-mentioned)<br> ))<br> <br> (define ext-grammar<br> (extend-language<br> basic-grammar<br> (C number string )<br>
(e .... C)<br> ))<br> <br> (define-metafunction sub<br> basic-grammar<br> [(((x_1) ... x_2 x_3 ...) (x_4 ... x_2 x_5 ...))<br> (sub (((x_1) ... x_3 ...) (x_4 ... x_2 x_5 ...)))]<br> [(((x_1) ... x_2 x_3 ...) (x_4 ... ))
<br> (sub (((x_1) ... (x_2) x_3 ...) (x_4 ...)))]<br> [(((x_1) ...) (x_4 ... ))<br> (x_1 ...)])<br> <br> (define-metafunction fv<br> basic-grammar<br> [x_1 (x_1)]<br> [(e_1 e_2) ,(append (term (fv e_1)) (term (fv e_2)))]
<br> [("lam" x_1 e_1) (sub ((fv e_1) (x_1)))]<br> )<br> <br> ;;?<br> (define-metafunction/extension fv1<br> ext-grammar<br> fv<br> [C_1 ()]<br> )<br> <br> (define ext2-grammar<br> (extend-language
<br> ext-grammar<br> (prim + - * /)<br> (C .... prim)<br> (e .... prim)<br> )<br> )<br> <br> #;(define test (term (fv1 ("lam" y ("lam" x (+ x y))))))<br> <br> #;(define test2 (test-match ext2-grammar e_1 '(+ ("lam" x (+ 1)))))
<br> <br> )<br><br>1. how can I use "define-metafunction/extension"? <br><br>firstly, it is inconvenient to rename fv to fv1<br>second, how can I reuse the definitions in fv?<br><br>btw, is there also a demo show on "define-multi-arg-metafunction"?
<br><br>2. a little suggestion: we see that ext2-grammar is something wrong which makes e and C all terminate on <br>prim. however, redex just accept it. so , test2 make multiple matches. For someone experienced to redex,
<br>there is a quickly respond to the grammar. But, for the freshes, it takes time to handle. So, I suggest redex<br>do a static check on this case and report a warning<br><br>thanks<br><br>Gang<br>