Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
The Medley Interlisp Project
The Medley Interlisp Project
@interlisp@fosstodon.org  ·  activity timestamp last month

An example of one way of defining, expanding, and calling an Interlisp macro similar to WHEN of Common Lisp. Macro definitions are represented by lists stored on the property list of a symbol. Here ARGS is bound to the CDR of the calling form.

#interlisp #lisp

Screenshot of a portion of the black and white desktop of a 1980s graphical workstation environment. The desktop has a gray background pattern and one window with a white background and a title bar with white text on a black background. The window is a Lisp REPL where the following expressions are evaluated, output printed, and values returned:

2/4_ (PUTPROP 'WHEN 'MACRO '(ARGS (LIST 'COND (CONS (CAR ARGS) (CDR ARGS)))))
(ARGS (LIST (QUOTE COND) (CONS (CAR ARGS) (CDR ARGS))))
2/5_ (GETPROP 'WHEN 'MACRO)
(ARGS (LIST (QUOTE COND) (CONS (CAR ARGS) (CDR ARGS))))
2/6_ (SETQ FOO 3)
3
2/7_ (EXPANDMACRO '(WHEN (GREATERP FOO 2)
                     (PRINT "Greater.")
                     T))
(COND
   ((GREATERP FOO 2)
    (PRINT "Greater.")
    T))
NIL
2/8_ (WHEN (GREATERP FOO 2)
       (PRINT "Greater.")
       T)
"Greater."
T
Screenshot of a portion of the black and white desktop of a 1980s graphical workstation environment. The desktop has a gray background pattern and one window with a white background and a title bar with white text on a black background. The window is a Lisp REPL where the following expressions are evaluated, output printed, and values returned: 2/4_ (PUTPROP 'WHEN 'MACRO '(ARGS (LIST 'COND (CONS (CAR ARGS) (CDR ARGS))))) (ARGS (LIST (QUOTE COND) (CONS (CAR ARGS) (CDR ARGS)))) 2/5_ (GETPROP 'WHEN 'MACRO) (ARGS (LIST (QUOTE COND) (CONS (CAR ARGS) (CDR ARGS)))) 2/6_ (SETQ FOO 3) 3 2/7_ (EXPANDMACRO '(WHEN (GREATERP FOO 2) (PRINT "Greater.") T)) (COND ((GREATERP FOO 2) (PRINT "Greater.") T)) NIL 2/8_ (WHEN (GREATERP FOO 2) (PRINT "Greater.") T) "Greater." T
Screenshot of a portion of the black and white desktop of a 1980s graphical workstation environment. The desktop has a gray background pattern and one window with a white background and a title bar with white text on a black background. The window is a Lisp REPL where the following expressions are evaluated, output printed, and values returned: 2/4_ (PUTPROP 'WHEN 'MACRO '(ARGS (LIST 'COND (CONS (CAR ARGS) (CDR ARGS))))) (ARGS (LIST (QUOTE COND) (CONS (CAR ARGS) (CDR ARGS)))) 2/5_ (GETPROP 'WHEN 'MACRO) (ARGS (LIST (QUOTE COND) (CONS (CAR ARGS) (CDR ARGS)))) 2/6_ (SETQ FOO 3) 3 2/7_ (EXPANDMACRO '(WHEN (GREATERP FOO 2) (PRINT "Greater.") T)) (COND ((GREATERP FOO 2) (PRINT "Greater.") T)) NIL 2/8_ (WHEN (GREATERP FOO 2) (PRINT "Greater.") T) "Greater." T
  • Copy link
  • Flag this post
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct