Re: [racket-users] Re: Help with macros

2016-09-22 Thread C K Kashyap
Super!!! ... thanks a ton Jens. Now I'll go over the docs to understand why it works :) Regards, Kashyap On Thu, Sep 22, 2016 at 8:52 AM, Jens Axel Søgaard wrote: > Here is a bit more. > > #lang racket > > (require (for-syntax syntax/parse racket/syntax) > syntax/parse/define) > > (defi

Re: [racket-users] Re: Help with macros

2016-09-22 Thread Jens Axel Søgaard
Here is a bit more. #lang racket (require (for-syntax syntax/parse racket/syntax) syntax/parse/define) (define-simple-macro (define-primitive-application-syntax (primitive-name:id arg:id ...)) (define-simple-macro (primitive-name arg-expr:expr (... ...)) (list 'primitive-name arg-

Re: [racket-users] Re: Help with macros

2016-09-22 Thread C K Kashyap
Thanks Jens ... I think I'm almost thereI get this "primitive-name: pattern variable cannot be used outside of a template in: primitive-name" at the very end now (require syntax/parse/define) (define-simple-macro (define-primitive-application-syntax (primitive-name:id arg:id ...)) (defi

Re: [racket-users] Re: Help with macros

2016-09-22 Thread Jens Axel Søgaard
Remove the (). The construct syntax-case needs the () which in general can be a list of identifiers, but most often an empty list, (), is used. Any identifiers in the list are treated by syntax-case as a literal. The construct syntax-parse does not use a list of identifiers. It uses an alternativ

Re: [racket-users] Re: Help with macros

2016-09-22 Thread C K Kashyap
Thanks Andrew ... I got past that error. I now get an error below - " syntax-parse: expected clause in: ()" (define-syntax (define-primitive stx) (syntax-parse stx () ; ERROR [(_ (primitive-name:id arg:id ...) body ...+) #:with table-name (format-id #'primitive-name "~a-prop

[racket-users] Re: Help with macros

2016-09-22 Thread Andrew Kent
The '...' that is causing the error is a '...' at the level of the _initial/outer_ macro (define-primitive-application-syntax), and so your final use of '...' is trying to splice a parameter of the _initial macro_ (define-primitive-application-syntax), but you are actually trying to output a _l

Re: [racket-users] Re: Help with macros

2016-09-22 Thread C K Kashyap
Thank you so much Jack, This certainly helps! I was following the tutorial http://www.greghendershott.com/fear-of-macros/ - It turns out that it too recommends syntax-parse at the very end :) When I tried this, I got "syntax: no pattern variables before ellipsis in template in: ..." (require syn

[racket-users] Re: Help with macros

2016-09-21 Thread Jack Firth
Your `syntax-rules` macro-defined macro uses the name "b", but that name is already bound by the `syntax-case` step of `define-primitive`. So your expansion looks like this: (define-primitive (add a b c d) (print (+ a b c d))) => (begin (define add-property-table (make-hash)) (hash-set! ad