Re: [racket] macro question

2014-10-02 Thread Neil Van Dyke
If you're not already using DrRacket's awesome Macro Stepper, give it a try, to see how your examples expand. Neil V. Racket Users list: http://lists.racket-lang.org/users

Re: [racket] macro question

2014-10-02 Thread Kevin Forchione
On Oct 2, 2014, at 6:53 PM, Ryan Culpepper wrote: > On 10/02/2014 09:19 PM, Kevin Forchione wrote: >> Hi guys, >> Why does this appear to work? I assume it’s not a recommended approach. >> >> #lang racket >> >> (require (for-syntax syntax/parse)) >> >> (define-syntax (mylet stx) >> (let ([v

Re: [racket] macro question

2014-10-02 Thread Ryan Culpepper
On 10/02/2014 09:19 PM, Kevin Forchione wrote: Hi guys, Why does this appear to work? I assume it’s not a recommended approach. #lang racket (require (for-syntax syntax/parse)) (define-syntax (mylet stx) (let ([val (syntax-case stx () [(_ x) #'x] [(_ x xs ...

Re: [racket] macro question

2014-10-02 Thread Sean Kanaley
(let ([x y]) x) => y That "let" is just a wrapper that equals y. So your macro is really (define-syntax (mylet stx) (syntax-case stx () [(_ x) #'x] [(_ x xs ...) #'(cons x (mylet xs ...))])]) Which causes (mylet 1 2 3) => '(1 2 . 3) ;don't forget the dot! And that's just the macro v

[racket] macro question

2014-10-02 Thread Kevin Forchione
Hi guys, Why does this appear to work? I assume it’s not a recommended approach. #lang racket (require (for-syntax syntax/parse)) (define-syntax (mylet stx) (let ([val (syntax-case stx () [(_ x) #'x] [(_ x xs ...) #'(cons x (mylet xs ...))])]) val)) (mylet 1

Re: [racket] macro question

2014-09-25 Thread Alejandro Zamora
Thanks Jay!! nice solution!! I'm asking for define-macro & R5RS because I'm trying to use one R5RS Embedded Scheme Interpreter on Python that have only define-macro construction for make macros and I want to use it. greetings! El Thu, 25 Sep 2014 10:17:49 -0400 Jay McCarthy escribió: > I won't

Re: [racket] macro question

2014-09-25 Thread Jay McCarthy
I won't answer the question about R5RS, but in Racket you can do this fairly succinctly: #lang racket/base (require (for-syntax racket/base racket/syntax)) (define-syntax (vars stx) (syntax-case stx () [(_ id count val) (with-syntax ([(id_i ...)

[racket] macro question

2014-09-24 Thread Alejandro Zamora
Hi Racket people: I have a (maybe too simple) question: How I create one macro like this (but using define-macro & R5RS language only)?: (vars sym var-cant val-of-vars) Example: (vars id 5 null) -> (prog (define id1 null)

Re: [racket] Macro question - `let' without inferring name?

2012-09-05 Thread Robby Findler
Also check out syntax-local-infer-name. Robby On Thu, Sep 6, 2012 at 6:19 AM, Carl Eastlund wrote: > You probably want to look at this section of the documentation: > > http://docs.racket-lang.org/reference/syntax-model.html#%28part._infernames%29 > > Carl Eastlund > > On Wed, Sep 5, 2012 at 11:

Re: [racket] Macro question - `let' without inferring name?

2012-09-05 Thread Erik Silkensen
Cool, thanks! Erik On Sep 6, 2012, at 12:08 AM, Eric Dobson wrote: > How about: > > (define-syntax (m stx) > (syntax-case stx () >[(m expr) > #'(let ([t (values expr)]) > ;; > t)])) > > Which seems to work for me. > > On Wed, Sep 5, 2012 at 8:56 PM, Erik Silkens

Re: [racket] Macro question - `let' without inferring name?

2012-09-05 Thread Carl Eastlund
You probably want to look at this section of the documentation: http://docs.racket-lang.org/reference/syntax-model.html#%28part._infernames%29 Carl Eastlund On Wed, Sep 5, 2012 at 11:56 PM, Erik Silkensen wrote: > Hi, > > I'm wondering if there's any way to have a macro like > > (define-syntax

Re: [racket] Macro question - `let' without inferring name?

2012-09-05 Thread Eric Dobson
How about: (define-syntax (m stx) (syntax-case stx () [(m expr) #'(let ([t (values expr)]) ;; t)])) Which seems to work for me. On Wed, Sep 5, 2012 at 8:56 PM, Erik Silkensen wrote: > Hi, > > I'm wondering if there's any way to have a macro like > > (define-syn

[racket] Macro question - `let' without inferring name?

2012-09-05 Thread Erik Silkensen
Hi, I'm wondering if there's any way to have a macro like (define-syntax (m stx) (syntax-case stx () [(m expr) #'(let ([t expr]) ;; t)])) that binds expr to t, does some things, and then somehow returns t -- but with whatever name would have been inferred for e