Skip to content

Tag Archives: Macros

What are syntax-case pattern variables?

I asked here: syntax-case takes a syntax object as an argument and destructures it via pattern matching into pattern variables. What are pattern variables composed of? syntax takes a template, and the pattern variables in it, to produce a syntax object that has the same lexical scoping as that of the pattern variable, so where [...]

Macros in Ruby

This looks like an interesting article about writing macros in Ruby.

Unhygienic macros inside of unhygienic macros are difficult

In this post; Ryan explains why unhygienic macros inside of unhygienic macros are often difficult. ;; the working if-it & when-it   (define-syntax (if-it stx) (syntax-case stx () ((if-it test? then else) (with-syntax ((it (datum->syntax #’if-it ‘it))) #’(let ((it test?)) (if it then else))))))   (define-syntax (when-it stx) (syntax-case stx () ((~ test? exp exp2 [...]

One reason for hygiene

You need hygiene because: Only superstars on their highest alert level [while writing macros] get things right all the time. –Matthias That said, hygiene alone isn’t a cure-all for writing predictable macros. If you don’t understand what you are doing, thoroughly; you will screw up eventually. “Thar be dragons here” as someone once warned on [...]

Automata via Macros

Last year I asked a question about Automata via Macros to the PLT Discussion List. The paper is about an extended example of a problem posed by Shriram Krishnamurthi at the Lightweight Languages 1 conference. I was trying to understand how one might use the same FSA language to generate different outputs. Many folks explained [...]

Scheme is mysophobic

Here is an interesting post about hygiene and its sociological impact on the two Lisp groups of Schemers and Common Lispers. While the post itself is a troll, the author: Uses a very accessible analogy. Quite clearly communicates a number of differences between Scheme and Common Lisp when it comes not only to hygiene but [...]

Anaphoric Macros

Does the convenience that anaphoric macros provide justify breaking hygiene? In that chapter of On Lisp, the author stated that: This chapter will show that variable capture can also be used constructively. There are some useful macros which couldn’t be written without it. My evaluation of that claim is that while the former is true, [...]

Companies using DSLs with Functional Programming Languages

One of the questions that has been lingering in the back of my mind for a long time is “When should a company use a DSL?”. My stock answer has always been “When it makes sense.” Perhaps a better way is to answer that question is to look at how companies are actually using them [...]

Rubys Upto in a Scheme macro

For a lot of folks, Ruby has a syntax that is really irresistible. Iteration is one of the things in particular that is described as being quite simply, fun. Here is how it works:

Code Generation and DSLs in Scheme

Over the years, I have heard some pretty outrageous and tantalizing claims made about the programming language Lisp. For example, “It will change you, forever.” and “You write code that writes code.”. Sadly, no further explanation is ever provided. Perhaps it is impossible to capture the essence of that to which these statements allude? This [...]