Re: [racket-users] Macro guards question

2019-05-29 Thread Kevin Forchione
> On May 29, 2019, at 11:09 AM, Sorawee Porncharoenwase > 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

Re: [racket-users] Macro guards question

2019-05-29 Thread Sorawee Porncharoenwase
The issue is that #'arg will always be a syntax object. An identifier is a kind of syntax object, so it makes sense to test (identifier? #’arg). However, (symbol? #’arg) and (string? #’arg) will always fail. Suppose then that you invoke the macro with "1" as the operand, it would fail every case

Re: [racket-users] Macro guards question

2019-05-29 Thread Ryan Kramer
#'arg is a syntax object, therefore (number? #'arg) or (string? #'arg) will always be false. If you are trying to dispatch based on literals, you could use e.g. (number? (syntax-e #'arg)) to identify a numeric literal. But it is not very common that a macro handles a numeric literal differently

[racket-users] Macro guards question

2019-05-29 Thread Kevin Forchione
Hi Guys, What are the rules for macro guards? I’ve only seen examples with (identifier? #’val) being used. What about (number? #’val) or (spring? #’val)? When I try these I get a foo: bad syntax so I’m suspecting these can’t be used or there’s some trick to them. What I’ve been trying to