[plt-scheme] quasiquote confusion with printable<%> interface
I'm trying to use the class system to model database fields. I'm
implementing the printable<%> interface, but weirdness is occurring.
Here's the Field% class:
(define Field%
(class* object% (printable<%>)
(init-field
name
[backend (new DatabaseBackend%)])
(super-new)
(define/public (custom-write port)
(write `(new Field% [name ,(send backend quote-name name)]) port))
(define/public (custom-display port)
(display (format "Field%: ~a" name) port))))
and when I create and write a Field%, everything works as expected.
> (define f (new Field% [name "blah"]))
> f
(new Field% (name "\"blah\""))
Here's a CharField%:
(define CharField%
(class Field%
(init-field
max-length)
(inherit-field backend, name)
(super-new)
(define/override (custom-write port)
(write `(new CharField%
[name ,(send backend quote-name name)]
[max-length ,max-length]) port))))
But when I try to create and write a CharField%, the unquote seems to
be ignored.
> (define cf (new CharField% [name "blah"] [max-length 20]))
> cf
(new CharField% (name ,(send backend quote-name name)) (max-length ,max-length))
What am I doing wrong?