Which Super Villain are you?
Here are my results:
You are The Joker
|
The Clown Prince of Crime. You are a brilliant mastermind but are criminally insane. You love to joke around while accomplishing the task at hand.![]() |
Here are my results:
You are The Joker
|
The Clown Prince of Crime. You are a brilliant mastermind but are criminally insane. You love to joke around while accomplishing the task at hand.![]() |
Awesomely inspired. For someone who enjoys Tolkien lore as much as I, this was a special treat (pun intended). Click on over to see the whole set.

Good advice from a paternal programmer to his progeny. (Read it first, then come back here.)
I read articles like this from time to time, and I see the truth in them. Still, I wonder if the advice goes beyond programming, but to almost any endeavor. There are a few others that I think are about as important as those:
Just a little friendly advice from one end of the interether to another.
While a provocative title, this post isn’t really that. It’s more about their similarities and how I learned to write a Scheme macro given a Lisp macro I had written a while back.
As a newbie to both languages, I can say that I was quite taken aback at the differences between Lisp and Scheme regarding macros. About the only thing they have in common is that they both operate at eval time rather than run time.
Lisp has a fairly straightforward syntax for macros. It uses a quasiquote system that takes a few parameters and returns an s-expression to be inserted where the original macro call took place.
As an example, here is a macro I wrote for my game (when I was doing a Lisp version). Given a list of names, it defines 3 variables: the list of names, a randomized array of indices into the array of names, and another small macro that references a name through the randomized array.
(defmacro def-items (item-type items)
(let ((ids-var (intern (concatenate 'string "*" (singular-form (symbol-name item-type)) "-IDS*")))
(names-var (intern (concatenate 'string "*" (singular-form (symbol-name item-type)) "-NAMES*")))
(func-var (intern (concatenate 'string (singular-form (symbol-name item-type)) "-NAME"))))
`(progn (defparameter ,names-var ,items)
(defparameter ,ids-var (make-array (length ,names-var)
:element-type 'integer
:initial-contents `(,@(loop for i upto (1- (length ,names-var)) collect i))))
(defmacro ,func-var (id)
`(elt ',,names-var (elt ,,ids-var ,id))))))
(def-items scrolls
'("scroll-GRISTOGRUE"
"scroll-Kho Reck Tighp"
"scroll-E Z"
"scroll-Kevitz"))
The def-items macro takes the list of scrolls and creates 3 variables at eval time by returning an s-expression that defines the 3 variables. (Note that the randomization is not present in this version for simplicity and brevity). The quasiquote (`) starts the s-expression to be returned, and each comma (,) means to evaluate the macro variable and put its value into the expression. Hopefully it is clear (as mud).
R5RS Scheme has something not nearly so simple or powerful (at least that I see. Remember, I’m a noob here.). It uses syntax-rules, a pattern matching system that works like a case statement over which substitution to return. There is no processing of the substitution. The biggest benefit of syntax-rules over Lisp macros that I see is that they are hygienic, meaning that you don’t have to worry about naming conflicts or accidents. To my knowledge, the above macro is not possible using syntax-rules. It could return an expression that could do all of this at run time, but not at eval time.
Kent Dybvig proposed a new syntax macro mechanism for Scheme, syntax-case. PLT Scheme and many other implementations provide syntax-case. It allows for the eval time processing of Lisp macros with the pattern matching and hygiene of syntax-rules.
As another example, here is the same macro in PLT Scheme:
(define-syntax (def-items stx)
(syntax-case stx ()
((def-items item-type items)
(begin
(unless (identifier? (syntax item-type))
(raise-syntax-error #f "item-type must be an identifier" stx (syntax item-type)))
(unless (pair? (cadr (syntax-object->datum (syntax items))))
(raise-syntax-error #f "items must be a list" stx (syntax items))))
(let ((ids-var (string-concatenate (list "*" (symbol->string (syntax-object->datum (syntax item-type))) "-ids*")))
(names-var (string-concatenate (list "*" (symbol->string (syntax-object->datum (syntax item-type))) "-names*")))
(func-var (string-concatenate (list (symbol->string (syntax-object->datum (syntax item-type))) "-name")))
(count (length (cadr (syntax-object->datum (syntax items))))))
(datum->syntax-object stx
`(begin
(define* ,(string->symbol names-var) ,(syntax items))
(define* ,(string->symbol ids-var) (vector ,@(list-of x (x <- 0 ..< count))))
(define* ,(string->symbol func-var)
(lambda (id)
(nth ,(string->symbol names-var) (vector-ref ,(string->symbol ids-var) id))))))))))
Look familiar? It should look remarkably similar to the Lisp macro with a few extra syntax calls thrown in, all wrapped in a datum->syntax-object call. It also adds in some extra checking such as making sure that the item-type is a symbol and that items is a list. The lisp macro could have done that as well, but I didn’t do it then. Also, this macro won’t work in vanilla PLT Scheme. I use the Swindle language pack that offers some niceties such as define* and nth.
It’s basically just as powerful as the Lisp macros, plus you get pattern matching and hygiene (though this macro didn’t need either). This is pretty cool stuff.