7.0.0.13

5 — Racket Languages 2

Due Tuesday, 13 Feb; 9:00am

Delivery Send me a zip file name 5-lastname1-lastname2.zip with your solutions. The zip archive should contain five files, each starting as follows:
; Problem Set 5
; Lastname1, Firstname1
; Lastname2, Firstname2
The five files should be named
  • 5-lastname1-lastname2-0.rkt, for the Defined language,

  • 5-lastname1-lastname2-ns-l.rkt, for the revised language implementation,

  • 5-lastname1-lastname2-ns-i.rkt, for the revised language client file,

  • 5-lastname1-lastname2-maze.rkt, for the maze navigation language, and

  • 5-lastname1-lastname2-maze.txt, a plain text file, that documents the maze navigation language.

image

Problem 0 Develop Defined, a Racket-like language, which pushes all definitions to the top of a module (in order) and leaves all expressions in place (in order). That is, it synthesizes a Racket module that consists of a sequence of definitions followed by a sequence of expressions. These definitions may include syntax (compile-time) functions that expand other top-level forms into define, and your language implementation must account for those too.

Thus, the following two programs ought to be equivalent:
#lang s-exp "Defined.rkt"
 
(define-syntax-rule
  (def head body)
  ; ==>
  (define head body))
 
(def x 0)
(set! x 1)
(def (f y) (+ x y))
(+ (f x) 1)

     

#lang s-exp "Defined.rkt"
 
(define-syntax-rule
  (def head body)
  ; ==>
  (define head body))
 
(def x 0)
(def (f y) (+ x y))
 
(set! x 1)
(+ (f x) 1)
Both also rewrite to the same program.

Problem 1 Modify the syntactic network language so that it also exports as much functionality as possible from Racket. This will allow "network syn lang" programmers—that is, the creators of the syntactic network clientto use argmax and argmin instead of maximize and minimize.

Note The purpose of this first step is to explore Racket’s capabilities of importing identifiers into modules, and exporting them from a module. This is a reasonably sophisticated sub-language all by itself.

Once you can use Racket’s argmax and argmin, develop a use case where the client program uses some other function. Demonstrate that it works with a modified client file.

Problem 2 Design a Racket-y languageMeaning a language that uses Racket’s beautiful syntax for navigating mazes like those in figure 2.

Figure 2: A garden maze

Topologically, a maze is an undirected graph with some nodes labeled entrance and some labeled exit. Your language should allow users to specify a maze and ask for solutions to questions such as
  • is there a path from some specific entrance to a particular exit, or

  • how can I get to some specific place inside the maze from any entrance.

Decide on the precise set of questions your Maze programmers can solve.

Design the language. Deposit any library with basic functionality as a submodule in the language-implementation file. Also create a brief plain-text file that documents your choices.