# Identifiers with dashes and the infix package

**URL:** <https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950>\
**Category:** Questions & Answers\
**Tags:** question\
**Created:** [June 3, 2024, 1:53pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950 "2024-06-03T13:53:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [June 3, 2024, 1:53pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950/1 "2024-06-03T13:53:37Z")

</div>

Hello,

Almost out of sheer curiosity, is there a way to use identifiers with dashes with the [infix package](https://docs.racket-lang.org/infix-manual/index.html), with or without `at-exp`?

I would like to be able to do something like this:

```scheme
#lang at-exp racket
(require infix)
(define my-variable 3)
@${my-variable + 1}

```

Here is the error message I am getting:

```scheme
; tmp.rkt:6:4: my: unbound identifier
; in: my

```

From the error message I infer that the class of identifiers `infix` accepts does not allow dashes, because they are treated as subtraction. I read the sources a little bit, but I couldn't see whether there is a way to escape `my-variable` to make the above example work.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 3, 2024, 2:44pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950/2 "2024-06-03T14:44:41Z")

</div>

You can use an underscore in infix mode:

```scheme
#lang at-exp racket
(require infix)
(define my-variable 3)
@${my_variable + 1}

```

It would be nice, if `|my-variable|` could be used. If you want to add that, look at [infix/infix/parser.rkt at master · soegaard/infix · GitHub](https://github.com/soegaard/infix/blob/master/infix/parser.rkt)

---

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [June 3, 2024, 3:20pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950/3 "2024-06-03T15:20:04Z")

</div>

Oh, great, thanks @soegaard !

I did think of `|my-variable|` as well, so it might be a cool side project indeed. Unfortunately, given my current time constraints, somebody will probably get around to implementing that before I do 😃

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [June 3, 2024, 3:48pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950/4 "2024-06-03T15:48:14Z")

</div>

As someone who enjoys whitespace as well as the liberal choice of characters for identifiers in lispy langs: I think another interesting design is to require space between most tokens.

In `1 + foo * 3`, AFAICT there's no ambiguity to disallow `foo` being `foo-bar`, `foo/bar`, or even `1foo` (as well as `|any chars|`), just like in Racket?

But that's probably not suitable for your existing infix library -- some people who prefer infix probably also like being able to minimize spaces and write things like `1+foo*3`. 😄

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 3, 2024, 4:09pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950/5 "2024-06-03T16:09:28Z")

</div>

I am just relieved that scolobb's identifier wasn't `my-variable*` 🙂

Or `my_variable` for that matter.

So quoting with || would be a great addition.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [June 7, 2024, 12:56pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950/6 "2024-06-07T12:56:55Z")

</div>

@scolobb I updated infix today. Now the syntax `|c*|` where c is any non-pipe character can be used. Thanks for the impetus to make the change.

---

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [June 7, 2024, 10:42pm UTC](https://racket.discourse.group/t/identifiers-with-dashes-and-the-infix-package/2950/7 "2024-06-07T22:42:25Z")

</div>

That's amazing @soegaard , thank you very much!
