Abandoned

Since infogami has been abandoned by its creators, I’m out too. Back to web.fisher.cx for me. Everything that was here is there.

Robert Fisher

Just thinking out loud

Scheme nand & nor

If you register and log in you can add comments to my pages. If viewing the main blog page, click the # underneath an entry to comment on it.

These are my first attempt at writing a Scheme macro.

Scheme macros note: R5RS gives a standard syntax-rules macro system. Some Scheme's provide a Common Lisp defmacro style system. There's also a syntax-case system. (Which generalizes both Common Lisp defmacro & R5RS syntax-rules?)

Here are nand & nor as syntax-rules.

(define-syntax nand
(d(syntax-rules ()
(d(s((_) #f)
(d(s((_ test ...) (not (and test ...)))))

(define-syntax nor
(d(syntax-rules ()
(d(s((_) #t)
(d(s((_ test ...) (not (or test ...)))))


From How to Use Modules in PLT Scheme v200:

The main difference between syntax-rules and syntax-case is that a pattern in syntax-case is followed by arbitrary code to be executed at expansion time. Within that code, a syntax form explicitly introduces a template.


Scheme