Writing Racket Macros: define-syntax and phases

19 May 2023
computer-science, racket

There are a bunch of different ways of writing a macro in Racket. There are also some tricky things around phases to keep in mind. This is to help me keep them all straight. 3+1 ways to make a macro # This form: (define-syntax-rule (foo args ...) (use args ...)) is equivalent to: (define-syntax foo (syntax-rules () ([foo args ...] (use args ...)))) Which, is in turn equivalent to: (define-syntax foo (λ (stx) (syntax-case stx () [(gensymed-foo args . ...

microKanren Reading

4 Jul 2022
tutorials, featured
programming-languages, racket

μKanren (“micro-Kanren”) is a tiny, embeddable logic programming language. It’s easy to understand and implement in almost any language. It’s a great case study of an embedded language: unlike other common “embedded” languages like SQL or regex, which normally are represented as just plain-old strings, μKanren takes more advantage of the host language’s features. I recommend reading the original paper: it’s short, well-written, and easy to understand. I did a write-up which you can read on Sourcehut. ...

A programmable programming language? I'll drink to that!

21 Aug 2021
personal, fun, racket

My wife and I got a chance to go to a place that lets you paint pottery and then have it fired. The pottery is all pre-made; you just get to paint it. It’s been a very long time since I’ve worked with a physical art medium, so the mug looks kinda dumpy. I did alright with the Racket logo on the bottom-inside of the mug though! I’m working on some fun projects with Racket. ...