3 ms·
Notice that MDL is almost Common Lisp: <DEFINE WAIT ("OPTIONAL" (NUM 3)) #DECL ((NUM) FIX) <TELL "Time passes..."> <REPEAT ((N .NUM
by lispm 9y ago
Notice that MDL is almost Common Lisp:
<DEFINE WAIT ("OPTIONAL" (NUM 3))
#DECL ((NUM) FIX)
<TELL "Time passes...">
<REPEAT ((N .NUM))
#DECL ((N) FIX)
<COND (<OR <L? <SET N <- .N 1>> 0>
<CLOCK-DEMON ,CLOCKER>
<FIGHTING ,FIGHT-DEMON>>
<RETURN>)>>>
(defun wait (&optional (num 3)) ; same arglist
(declare (fixnum num)) ; similar declaration
(tell "Time passes...") ; some call
(repeat ((n num)) ; some loop macro, see below
(declare (fixnum n)) ; declaration
(cond ((or (< (setq n (- n 1)) 0) ; old-style COND, OR, <, SETQ, -
(clock-demon clocker) ; some call
(fighting fight-demon)) ; some call
(return))))) ; return from loop
Where REPEAT would be implemented as:
(defmacro repeat (vars decl &body body)
`(let ,vars
,decl
(loop (progn ,@body))))
Common Lisp basically got type declarations, rich argument lists, ... from MDL.
- kazinator 9y agoI read parts of the MDL manual. It supported hacks whereby it could shift to using parentheses, as well as evaluation/quoting conventions that are more like Lisp.
- bluefox 9y agoIndeed... as soon as I saw this, I skimmed the (smug towards Lispers!) MDL primer [0] and wrote a few (broken) esrap rules to parse some MDL into Lisp. For example yours gives: DEMUDDLE> (parse 'expr *lispm-expr*) (DEFINE 'WAIT ("OPTIONAL" (NUM 3)) (TYPED DECL ((NUM) FIX)) (TELL "Time passes...") (REPEAT ((N (LVAR NUM))) (TYPED DECL ((N) FIX)) (COND ((OR (L? (SET 'N (- (LVAR N) 1)) 0) (CLOCK-DEMON (GVAR CLOCKER)) (FIGHTING (GVAR FIGHT-DEMON))) (RETURN))))) Someone more determined could write a small MDL->CL translator and produce a CL port of Zork (chock full of special declarations, since MDL uses dyamic scoping). I also found the following interesting remark in the primer: "One of the implementors of Zork has been heard to say that Zork is a huge conditional". [0] http://publications.csail.mit.edu/lcs/pubs/pdf/MIT-LCS-TR-292.pdf http://publications.csail.mit.edu/lcs/pubs/pdf/MIT-LCS-TR-29...