8.18
top
← prev up next →

postfix-dot-notationπŸ”— i

source code: https://github.com/AlexKnauth/postfix-dot-notation

1#lang postfix-dot-notationπŸ”— i

A lang-extension like at-exp that adds postfix-dot-notation to a language at the reader level.

Code like a.b is read as (ba), a.b.c is read as (c(ba)), and so on.

If you want to use an identifier that is supposed to have a dot in it, there are two cases where dot notation is disabled:
  • When an identifier is wrapped in ||, it is treated just like a normal identifier wrapped in ||. This means you can still use identifiers like |~.a| from racket/format or |pi.t| from racket/extflonum.

  • When an identifier begins with a ., it is treated as a normal Identifier. This means that identifiers like ... and .... work as normal.

(define x"hello-world")
x.string->symbol ;'hello-world
(struct foo(abc))
(define y(foo123))
y.foo-a;1
y.foo-b.number->string ;"2"
(parameterize ([error-print-width 10]);"(Iama..."
(|~.a| ' (Iamalonglist thatspansmorethan(error-print-width ))))
(match ' (123);'(23)
[(list 1rst... )rst])

2postfix-dot-notation for requireπŸ”— i

This works through #%top , not at the reader level, so it only works when there is an undefined identifier with a dot in it.

Examples:
> (require postfix-dot-notationracket/local)
> (let ([x"hello-world"])
x.string->symbol)

'hello-world

> (local [(struct foo(abc))
(define x(foo123))]
(values x.foo-a
x.foo-b.number->string))

1

"2"

syntax

( #%top . id)

The form that converts undefined identifiers that have dots in them, such as a.b to (ba), if b is defined and a is either defined or another identifier with a dot that can be converted like this.

top
← prev up next →

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /