Interpreter Project:

Extension C

define-syntax-rule and miscellaneous items

All parts due: NOON on Sunday, May 12th

Reminder: Notes about extensions

Extension C, like previous Extensions, serves three purposes. The extensions will...

  1. ...give you a much more detailed understanding of the material.
  2. ...make your interpreter more complete.
  3. ...provide you a chance to earn some extra credit.
It is extremely important to note that you should not be attempting any of the Extensions unless you are completely finished with all previous parts. You will lose far more points for failing to complete required sections of the interpreter than you could possibly gain by completing all of the Extensions.

You may attempt to complete the Extensions at any point during the project. You do not need to attempt them after a specific required portion of the project. In addition, you should not run handin37 separately to hand in an extension: simply hand in the extension along with the next required section you complete.

Finally, since these extensions are considered "advanced" features, you will receive far less guidance in completing them than you will receive for the required portions of the project. This does not mean that you cannot ask questions; rather, I will provide less information to you up front, forcing you to work out details on your own.

Implementing define-syntax-rule

Implementing syntax rules can be quite difficult. You may wish to pursue other Extensions before attempting this one. You should play around with syntax rules in DrRacket for a bit to see if you can figure out what is going on with them. Here are a few of the most basic things you need to know about them:

  1. Syntax rule definitions are always of the form:
    (define-syntax-rule (rule-name arg0 arg1 ...)
       expression
     )
    
  2. The expression in the syntax rule is evaluated in a "clean" environment which has the definitions of the primitives, but no other bindings.
  3. After substituting the arguments in the expression, the expression is then evaluated in the current environment.
Once you've got syntax rules working, you can test them out by running the code we wrote for streams.

Miscellany

If you can't get any of the other major Extension pieces to work properly, you can try some smaller things for partial-extra-credit:

  1. Allow functions to take arbitrary numbers of arguments. For example:
    ; Allows the function to take 1 or more arguments
    (define f 
      (lambda (first . list-of-optional-arguments)
         '...))
    
    
    or
    ; Allows the function to take 0 or more arguments
    (define f   
      (lambda list-of-optional-arguments 
         '...))
    
  2. Allow users to define procedures using the shortcut notation used in the textbook. For example, the following two statements are identical in Racket:
    (define f (lambda (n) (+ n 1)))
    
    (define (f n) (+ n 1))
    
  3. If you have another interesting idea, come talk to me about it. It's possible your idea is too hard, and I'd like to make sure you don't waste your time -- unless you really want to.

Extension C may be completed at any stage of the final project and does not need to be turned in separately.