An odd restriction

As I mentioned before, I’ve ported Gambit Scheme to my iTouch, and have been playing around with it a little. It’s pretty nice all in all, but I recently ran into a small problem while I was trying to play around with macros. The problem? There’s no way to enter a backtick (`) on the iTouch! That means that I don’t really have a way to write code like

1
`( a b ,(+ 1 2) d)

which makes writing macros a lot more painful. Fortunately, I got a lot of help from the people on IRC and on the Gambit mailing list. Specifically, Marc Feeley, the author of Gambit, posted a snippet of code that I could put into my .gambcini file that would add $ as a synonym for `. The code looked like this:

1
2
3
4
5
6
7
(begin
  (##readtable-char-class-set!
    (current-readtable)
    #\$  ;; the character to dispatch on
    #t   ;; this character is a delimiter
    (lambda (re c) (##read-quotation re #\`)))  ;; handler
  #f)

and the example, which works, is:

1
2
$(1 ,(+ 2 3) 4)
output: (1 5 4)

If you’re trying to write that code on your iTouch, you might notice that it includes the forbidden `, and so you’re once again out of luck. Except that in this case, you can replace #\` with #\u0060, which you can type in on the iTouch, and then it’ll all work.