so how would I wrote a macro that reverses an expression using sysntax rules only in #guile ?

Can you provide an example of what you are looking for?


I'm considering of porting to guile this paragraph (Transform!)

ans when I reach 3.3 I can't reproduce the reversion of an expression

Maybe I can try something tonight.
(If only I had Guile on my Android phone...)

The eval call smells bad to me haha

(define-syntax reverse-me
(syntax-rules ()
((reverse-me args args* ...)
(eval (reverse (list args args* ... values)) (interaction-environment)))))



this solutions does work, I guess, but I'm afraid it's not idiomatic Guile or Scheme

Do you really need to involve environments and eval to reverse an expression ?

Haha there are surely other ways. I don't really know what idiomatic means.

I just hacked in the REPL for 10 minutes. Trying to get the same output as the exercise example 👍


I'm not sure this is what I wanted, as I'm a bit confused now

But this seems to do the job

(reverse-me stx)
(reverse (syntax stx))


@AbbieNormal I can't make it to work in my REPL 😕

· · Web · 1 · 0 · 0


I call i tlike this

(reverse-me ("mom!" "hi"))

it's a bit naive, admittedly 😐


the thing is I'm reading that Racket tutorial and parallely also the Guile manual

But the mismatches are more and wider than I thought

@AbbieNormal @jeko What are some big surprises?

I've almost only done Racket, but I thought Racket and Guile are both basically R5RS with a dash of R6RS except Racket and Guile do packages differently, Racket has the hash-lang system and Racket has immutable cons cells by default. And then of course both add some libs and syntax on top of base Scheme.

@clacke @jeko

I need some time to wrap up what I found

I'll write about it tomorrow morning, if you don't mind

In the morning I have a few graceful moments in which I can focus

@AbbieNormal @jeko Answer in your own time, or not at all, it's you putting in the work because you want to help. I merely expressed my interest, you have no obligations toward me. =)

@clacke @jeko

there were some misunderstandings on my side

Now, I think I mapped most of the Racket tutorial on Guile things

Notably, the Racket tutorial doesn't treat syntax-rules because Racket hasn't them

It jumps durectly to syntax-case

And the define-syntax-rule in Racket is for syntax-case, in Guile is for syntax-rules, as far as I understand

@clacke @jeko

another notable thing is I can't return syntax objects from a lambda like the Racket tutorial does

I can pass them as arguments to display, though

at least I can have them displayed in the REPL

@clacke @jeko

overall I'm satisfied

it took me years to grasp the macros

the documentation is abysmal and probably I wasn't ready neither

Kudos to the author of this tutorial

@AbbieNormal @jeko Yeah, syntax objects aren't actually a thing in R5RS, it only presents a restricted use of macros that probably-not-coincidentally happens to be compatible with the more general notion of syntax objects.

Any use other than "syntax-rules inside a define-syntax" will be implementation-specific.
@AbbieNormal @jeko syntax-rules and syntax-case are two different chapters under… .

syntax-rules is from R5RS and define-syntax-rule is a shortcut for define-syntax + syntax-rules when there is only one rule.

@clacke @jeko

ah, it's 2 different chapters in the official documentation, good to know

But I was referring to this tutorial

@AbbieNormal @jeko Oh, I see:

> It’s called syntax-case, and has a shorthand for simple situations called define-syntax-rule.

Oh, I see. The author forgot the intermediate step: syntax-rules is a shorthand of syntax-case for simple (the vast majority of) situations, and define-syntax-rule is for the simplest case of syntax-rules.
@jeko @AbbieNormal Racket documentation is precise and complete, but often not entirely helpful as a guide. There is definitely a need for friendlier material.
Inscrivez-vous pour prendre part à la conversation

Le réseau social de l'avenir : Pas d'annonces, pas de surveillance institutionnelle, conception éthique et décentralisation ! Possédez vos données avec Mastodon !