> On May 29, 2019, at 11:09 AM, Sorawee Porncharoenwase 
> <sorawee.pw...@gmail.com> wrote:
> 
> (foo a) ;=> 1
> (foo "a") ;=> 2
> (foo 10) ;=> 3
> (foo 'a) ;=> 4
> (foo (bar x)) ;=> 5
Ah… thanks so much for the explanation. That’s put me much closer (I hope!) to 
the solution I’m after. A bit of stumbling around through some documentation 
has got me this far.Being able to handle (foo a) and (foo b) below differently 
is a distinction I’ve been after for a while!

#lang racket

(define-syntax (foo stx)
  (syntax-case stx ()
    [(_ arg) (and (identifier? #'arg) (identifier-binding #'arg 0 #t)) #'1]
    [(_ arg) (identifier? #'arg) #'2]
    [(_ arg) (string? (syntax->datum #'arg)) #'3]
    [(_ arg) (number? (syntax->datum #'arg)) #'4]
    [(_ (quote* x)) (and (free-identifier=? #'quote* #'quote)
                         (symbol? (syntax->datum #'x))) #'5]
    [(_ _) #'6]))

(define a #t) ;=> a is top-level bound, b is not.

(foo a)       ;=> 1
(foo b)       ;=> 2
(foo "a")     ;=> 3
(foo 10)      ;=> 4
(foo 'a)      ;=> 5
(foo (bar x)) ;=> 6


Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/506321EF-0D5B-4551-8671-268E6808B015%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to