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
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
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 ...
(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
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
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
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 ...)
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)
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:
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
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
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
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
13 matches
Mail list logo