Giter Club home page Giter Club logo

Comments (4)

leafac avatar leafac commented on August 19, 2024

Opening this Issue revealed a fundamental misunderstanding of Racket's syntax when it comes to pipes (|). It turns out that my expectations were wrong—Redex's typesetting was right.

See the corrected snippet, with escapes on every | within the identifier:

#lang racket
(require redex)

(define-language pipe
  [operator ::= \| \|\| \|\|\|])

(module+ test
  (test-equal (redex-match? pipe operator (term \|)) #t)
  (test-equal (redex-match? pipe operator (term \|\|)) #t)
  (test-equal (redex-match? pipe operator (term \|\|\|)) #t))

(render-language pipe)

Now the typeset version is what I wanted:

untitled_3_-_drracket

If someone wants to explain what || means and how typesetting worked on my wrong example, I'd be thankful.

from redex.

rfindler avatar rfindler commented on August 19, 2024

Glad you got this sorted out!

from redex.

bennn avatar bennn commented on August 19, 2024

In Racket, || is the empty identifier.

Because identifiers are scoped symbols, and any string can be turned to a symbol -- even "⇒" or "λ" or "hello world" -- and we need something to delimit symbols containing whitespace. The delimiter happens to be |:

> (string->symbol "hello world")
'|hello world|

I guess | is the delimiter because it's close to the other delimiters on many keyboards and looks kind of like braces.

For the official explanation, search for "|" in the docs: link

from redex.

leafac avatar leafac commented on August 19, 2024

@bennn: Thank you for the explanation. I understand what is going on, now.

I didn't know I could search for punctuation on Racket documentation. In all other search engines that I used, it doesn't work, so I just never thought of trying.

Racket keeps impressing me! 👍

from redex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.