[gambit-list] Quasiquote syntax question.
Blake Winton
bwinton at latte.ca
Fri Feb 1 23:25:24 EST 2008
Taylor R Campbell wrote:
> (I'ld even live with ($ a b c), but I can't seem to get that working either.)
> Try
> (define-syntax $
> (syntax-rules ()
> (($ x) (quasiquote x)))),
*** ERROR IN (console)@1.32 -- Ill-formed expression
> (define-macro ($ x)
> (list 'quasiquote x)).
This seems fine, but...
($ a b ,(+ 3 2) c)
*** ERROR IN (console)@6,1 -- Ill-formed special form: $
> (This is subtly different from what I am guessing you asked for, but
> more general: I am guessing that by ($ a b c) you meant `(a b c), but
> in that case you have no way to write `a for something that is not a
> list (e.g., a vector). This may not matter to you -- modifying the
> above macros to do that is left as a trivial exercise for the reader.)
Oh, wait:
($ (a b ,(+ 1 2) c))
(a b 3 c)
Okay, that's cool.
Just to check, would the modification be:
(define-macro ($ . x)
(cons 'quasiquote x))
? Nope.
*** ERROR IN (console)@10.1 -- Ill-formed special form: quasiquote
I'll play around with that some more.
> Alteration of the $ character in the readtable is generally a bad
> idea, because there may be many legitimate symbols that begin with it,
> which you would be left with no way to name.
I'm open for suggestions for other characters. € perhaps?
> Alternatively, is there really no way for you to enter a backtick, or
> to translate the $ key stroke to a ` character? If you used $, your
> code would be very confusing for anyone who tried to read it.
Yeah, there really isn't. I expect my macro code to be a little
confusing, but since I'm only going to be programming throw-away scripts
on the device, I'm hoping it won't really affect anyone.
Alex Shinn wrote:
> Blake> Hello everyone, I'm using Gambit on an iPod Touch, and have
> Blake> run into a small hitch when trying to write a macro. The
> Blake> hitch is that I have no way of typing in a ` on the device.
> Blake> It's just not on the keyboard.
>
> That's funny... ` is the only printable ASCII character it
> lacks. It has the pound, euro and yen signs, and several
> international keyboards, and no possible way to input `.
Yeah, go figure, eh? It's like they're trying to drive everyone to
Python (or just away from APL ;).
> But, how can you possibly code on that thing anyway? Apart from
> the pain of the horrid keyboard, there's the fact that you have
> no editor support. I would just ssh in from a real terminal, or
> cross-compile.
Ya know, I'm getting used to the keyboard quicker than I thought I
would, and I've got vi on it, and there's a graphical editor, as well.
When I'm at my desk at work, or at home, I do ssh in, but when my wife
and I are watching TV (which doubles as the computer monitor), or when
I'm on the subway, it's nice to be able to still hack.
And finally, Marc Feeley wrote:
> Beware, fiddling with Gambit's internal routines will void the
> warranty...
Heh. I think I've already done that by porting it to the iPhone in the
first place. :)
> > (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)
> > $(1 ,(+ 2 3) 4)
> (1 5 4)
I just tried to type this in on the device, but it seems to have a ` in
the middle of it. :P On the plus side, I ssh-ed in, and saved that as
.gambcini and then, on the device,
> $(1 ,(+ 2 3) 4)
(1 5 4)
Sweetness!
Thank you all for your help,
Blake.
More information about the Gambit-list
mailing list