Two question about scheme syntax in EOPL3

64 views
Skip to first unread message

ziqiang bao

unread,
Dec 10, 2013, 10:33:00 AM12/10/13
to eo...@googlegroups.com
My first question:
3.2.1 Specifying the Syntax
(scan&parse "-(55, -(x,11))")
#(struct:a-program
#(struct:diff-exp
#(struct:const-exp 55)
#(struct:diff-exp
#(struct:var-exp x)
#(struct:const-exp 11))))

Here what does '#' do? I do not know how to use it.

My 2ed question
3.2.4 Specifying the Behavior of Expressions 
(value-of (diff-expexp1 exp2) ρ)
= (num-val
    (-(expval->num (value-ofexp1 ρ))
      (expval->num (value-ofexp2 ρ))))

Here what does '-' stand for? I have not seen such usage for '-'.


Mitchell Wand

unread,
Dec 10, 2013, 5:10:04 PM12/10/13
to eopl3
3.2.1  The #(struct:a-program ...) is how Racket prints out structures.  Try the following in the interaction window:

(define-struct foo (field1))
(define a-foo (make-foo 3))
a-foo

3.2.2.  The - is subtraction, as in (- 3 2).

--Prof. Wand


--
You received this message because you are subscribed to the Google Groups "EOPL3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eopl3+un...@googlegroups.com.
To post to this group, send email to eo...@googlegroups.com.
Visit this group at http://groups.google.com/group/eopl3.
For more options, visit https://groups.google.com/groups/opt_out.

ziqiang bao

unread,
Dec 16, 2013, 9:37:38 AM12/16/13
to eo...@googlegroups.com
Thank you very much, Prof.Wand.
These days, I meet two other questions.
1.  In page 60 of EOPL3,  figure 3.2,  one can see
Expression ::= -(Expression , Expression)
                    diff-exp (exp1 exp2)
here, what does "-" mean?  it seems do not like substraction.

2. In the page 60, 
(scan&parse "-(55, -(x,11))")
 #(struct:a-program
     #(struct:diff-exp
        #(struct:const-exp 55)
            #(struct:diff-exp
              #(struct:var-exp x)
              #(struct:const-exp 11))))
Here, what does "scan&parse" mean ? In racket, I do not find its defintion.

ps: My english is not good.~ Thanks again. 


2013/12/11 Mitchell Wand <wa...@ccs.neu.edu>

Mitchell Wand

unread,
Dec 17, 2013, 3:17:22 PM12/17/13
to eopl3
On Mon, Dec 16, 2013 at 9:37 AM, ziqiang bao <vsfl...@gmail.com> wrote:
Thank you very much, Prof.Wand.
These days, I meet two other questions.
1.  In page 60 of EOPL3,  figure 3.2,  one can see
Expression ::= -(Expression , Expression)
                    diff-exp (exp1 exp2)
here, what does "-" mean?  it seems do not like substraction.

Here the minus sign is the symbol in the program that is intended to denote subtraction.  For example, the string 
"-(30,5)"  is an expression that will evaluate to 25.


2. In the page 60, 
(scan&parse "-(55, -(x,11))")
 #(struct:a-program
     #(struct:diff-exp
        #(struct:const-exp 55)
            #(struct:diff-exp
              #(struct:var-exp x)
              #(struct:const-exp 11))))
Here, what does "scan&parse" mean ? In racket, I do not find its defintion.

scan&parse is the function that converts a string to its syntax tree.  See Appendix A, and look in the code repository https://github.com/mwand/eopl3 .  scan&parse is usually defined in the lang.scm of each language.

--Prof. Wand

Reply all
Reply to author
Forward
0 new messages