Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Matthew Butterick
> On Sep 17, 2018, at 11:57 AM, Kevin Forchione wrote: > > In a nutshell I’m working with some hash tables whose keys are symbol and > whose values may be other keys or values such as identifiers, and I got a bit > tired of quoting all my symbols for functions and decided to use some macros

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Kevin Forchione
> On Sep 16, 2018, at 10:07 PM, Matthew Butterick wrote: > > >> On Sep 16, 2018, at 2:13 PM, Kevin Forchione > > wrote: >> >> Thanks! That’s just what I wanted. Is there a way in Racket to determine if >> a quoted symbol has an associated procedure? > > > >

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Alexis King
> On Sep 17, 2018, at 12:21, Kevin Forchione wrote: > > That seems to be the nature of macros, and I’m not sure what the solution to > that paradox is, apart from perhaps building a symbol/function hash table as > part of a define. Presumably Racke does something like that for eva & >

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Matthew Butterick
> On Sep 17, 2018, at 10:21 AM, Kevin Forchione wrote: > > That seems to be the nature of macros, and I’m not sure what the solution to > that paradox is, apart from perhaps building a symbol/function hash table as > part of a define. Presumably Racke does something like that for eva & >

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Philip McGrath
It might help to know a bit more context about what you're trying to do. I think other Lisp-family languages use these terms in different ways, but in Racket it isn't usual to talk about a symbol being bound to something. A symbol is just a type of value (like an integer, a list, a vector, a

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Kevin Forchione
> On Sep 16, 2018, at 10:07 PM, Matthew Butterick wrote: > > #lang racket > (require rackunit) > > (define-syntax (bound-to-proc? stx) > (syntax-case stx () > [(_ 'x) > (and (identifier? #'x) (identifier-binding #'x)) > #'(procedure? x)] > [_ #'#f])) > > (define

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-16 Thread Matthew Butterick
> On Sep 16, 2018, at 2:13 PM, Kevin Forchione > wrote: > > Thanks! That’s just what I wanted. Is there a way in Racket to determine if a > quoted symbol has an associated procedure? #lang racket (require rackunit) (define-syntax (bound-to-proc? stx)

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-16 Thread Kevin Forchione
> On Sep 15, 2018, at 7:27 PM, Philip McGrath wrote: > > Sure. For example: > > #lang racket > > (require syntax/parse/define > rackunit) > > (define-syntax-parser foo > [(_ arg:id) >#''arg] > [(_ arg:expr) >#'arg]) > > (check-eqv? (foo 10) 10) > (check-eq? (foo hello)

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-15 Thread Philip McGrath
Sure. For example: #lang racket (require syntax/parse/define rackunit) (define-syntax-parser foo [(_ arg:id) #''arg] [(_ arg:expr) #'arg]) (check-eqv? (foo 10) 10) (check-eq? (foo hello) 'hello) (check-pred procedure? (foo (λ (x) (* 2 x -Philip On Sat, Sep 15, 2018 at

[racket-users] [Racket Users] Macros and literals question

2018-09-15 Thread Kevin Forchione
Hi guys, Is there a way to define a macro so that an argument will be quoted only when it is a symbol? Something like this: (foo 10) => 10 (foo hello) => ‘hello (foo (lambda (x) (* 2 x))) => etc. Kevin -- You received this message because you are subscribed to the Google Groups "Racket