Questions tagged [syntax-rules]

For questions about the syntax-rules macro facility of the Scheme programming language.

21 questions
1
vote
1 answer

Why is my (guile) scheme macro evaluating its argument?

Within Guile, I am trying to learn define-syntax and syntax-rules. I was under the impression that scheme macros do not evaluate their arguments, but it seems like mine is doing so: (define-syntax foo (syntax-rules () ((foo word) …
beguiler
  • 13
  • 3
1
vote
1 answer

Scheme syntax-rules matching any number of pattern variable before a literal?

I'm trying to write a macro that substitutes some literal in an expression with a value, such as (substitute 3 (+ 4 1 _ 1 5)) This is what I have so far, (define-syntax substitute (syntax-rules (_) ((substitute val (_ e1 ...)) (val e1…
1
vote
1 answer

Provide syntax-rule Racket

How do I provide syntax rules in racket? I have code which is similar to this: (define-syntax SELECT (syntax-rules (FROM WHERE star) [(SELECT colnames FROM relnames) ...] [(SELECT colnames FROM relnames WHERE . expression) …
Atonic
  • 509
  • 1
  • 5
  • 14
1
vote
2 answers

How clojure macro parses special symbol?

When I re-implement a macro written in Scheme with Clojure, I get into a trouble. The macro tries to load pairs of testing data into a all-tests var for later use. Because the arguments for the macro is variable-length and contains special undefined…
GZ92
  • 151
  • 1
  • 10
0
votes
0 answers

Is it possible to define anaphoric macros using syntax-rules only?

Is possible to write anaphoric macros (e.g. aif) using syntax-rules only? Such a macro would need to break the hygiene of the macro system. I know that this is possible with syntax-case, but is it somehow possible with syntax-rules in R5RS and…
Flux
  • 9,805
  • 5
  • 46
  • 92
0
votes
1 answer

Introducing a Named Variable with Syntax Rules

I am trying to write a super-tiny Object-oriented system with syntax-rules, mostly just to learn it. Anyway, I am trying to introduce a "this" variable. Here is what I would like to be able to do: (oo-class Counter ( (attr value 0) …
johnnyb
  • 622
  • 5
  • 17
1
2