(define-syntax nth
(syntax-rules ()
((_ #(expr "list") n)
(list-ref expr n))
((_ #(expr "vector") n)
(vector-ref expr n))
((_ #(expr "string") n)
(string-ref expr n))
((_ spec n)
(spec n))))
Oh yeah... another idea...
If a "generic" like 'nth' appears as a call and it's argument is a
"typed symbol" e.g.
(define (string-first #(s "string"))
(nth s 0)
then the dispatch happens. But, if it appears "stand alone", for example
as an argument to another procedure, or if you pass it something besides
a typed symbol, it expands into a "slow nth" which essentially does the
work at runtime. Perhaps this dynamic behaviour should be
optional/configurable. I.e. if you don't specify a case for the runtime
option, you get a compile-time notice.
Ed