# Error in syntax-parse

**URL:** <https://racket.discourse.group/t/error-in-syntax-parse/494>\
**Category:** Questions & Answers\
**Created:** [December 30, 2021, 12:14am UTC](https://racket.discourse.group/t/error-in-syntax-parse/494 "2021-12-30T00:14:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [December 30, 2021, 12:14am UTC](https://racket.discourse.group/t/error-in-syntax-parse/494/1 "2021-12-30T00:14:17Z")

</div>

hello,  
i have this error in this code:

```scheme
#lang racket
(require syntax/parse)
(require syntax/strip-context)
(define (emit-interaction stx)
  (syntax-parse stx
    #:context '|error while parsing interaction|
		[(_ expr-or-def)
                 (strip-context (syntax expr-or-def))]))

```

(emit-interaction 10)  
error while parsing interaction: bad syntax in: 10

what is wrong? i just want to get 10 without error,even if it seems silly...

---

<div class="post-metadata">

**Author:** ![jbclements](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/jbclements/32/11_2.png) [@jbclements](https://racket.discourse.group/u/jbclements)\
**Post date:** [December 30, 2021, 4:32am UTC](https://racket.discourse.group/t/error-in-syntax-parse/494/2 "2021-12-30T04:32:02Z")

</div>

I think you meant to write

```scheme
(define-syntax (emit-interaction stx)
  ...)

```

rather than

```scheme
(define (emit-interaction stx)
  ...)

```

no?

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [December 30, 2021, 9:11am UTC](https://racket.discourse.group/t/error-in-syntax-parse/494/3 "2021-12-30T09:11:22Z")

</div>

no 🙂

doing this make an error:  
_: wildcard not allowed as an expression  
after encountering unbound identifier (which is possibly the real problem):  
syntax-parse in: (_ expr-or-def)

the solution was:

```scheme
(define (emit-interaction stx)
  (syntax-parse stx
    #:context '|error while parsing interaction|
		[(~var expr-or-def)
                 (strip-context (syntax expr-or-def))]))

```

but i find yesterday that i can do the same with:

(datum-\>syntax #f result)

i mean (emit-interaction 10) create the same strange syntax object than (datum-\>syntax #f 10)

same thing if argument is a variable:

(define x 3)  
(emit-interaction x)

(datum-\>syntax #f x)

the two syntax create an object syntax , i needed this strange macro with parse-syntax because a simple one with an identifier as argument would have return a syntax object with containing identifier and not the value stored in identifier.

Damien

---

<div class="post-metadata">

**Author:** ![simonls](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/simonls/32/170_2.png) [@simonls](https://racket.discourse.group/u/simonls)\
**Post date:** [December 30, 2021, 2:55pm UTC](https://racket.discourse.group/t/error-in-syntax-parse/494/4 "2021-12-30T14:55:59Z")

</div>

I agree with @jbclements and additionally you also want to use `(require (for-syntax syntax/parse syntax/strip-context))`. Without `for-syntax` you get en error messages because the syntax-parse needs to be required at syntax phase (matching the `define-syntax`).

> [@damien\_mattei](#):
>
> doing this make an error:  
> _: wildcard not allowed as an expression  
> after encountering unbound identifier (which is possibly the real problem):  
> syntax-parse in: (_ expr-or-def)

Note the last two lines telling you that `syntax-parse` is not bound (because of missing `for-syntax`).

If you turn your emit-interaction into a non macro by just using define you might as well write it as a function:

```scheme
(define x 3)
(define emit-interaction identity)
(emit-interaction x)
;; or alternatively
x

```

Please provide more context on what you are trying to accomplish, currently I don't understand what your actual goal is.

---

<div class="post-metadata">

**Author:** ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)\
**Post date:** [December 30, 2021, 3:51pm UTC](https://racket.discourse.group/t/error-in-syntax-parse/494/5 "2021-12-30T15:51:59Z")

</div>

Yes i will post in another thread the whole code.Consider this problem solved. The 2 solutions was equivalent, i will use simplest one, the two solutions are not portable to another Scheme.
