Questions tagged [reader-macro]

a way to program the Common Lisp reader

Reader macros provide a way to program the Common Lisp reader, which reads s-expressions and turns them into data. A typical use is to read new data types or to provide convenient notations.

39 questions
2
votes
4 answers

Use of # a.k.a. read-macro

Reading book "Let Over Lambda" by Doug Hoyte, I found the following description of #. sign, a.k.a. read-macro: A basic read macro that comes built in with COMMON LISP is the #. read-time eval macro. This read macro lets you embed objects into the…
Mark Karpov
  • 7,499
  • 2
  • 27
  • 62
1
vote
1 answer

How to disable a reader macro?

I used local-time's reader macro, until the moment I realized I don't need it (want to read back a date? Just use format or local-time:format-datestring and it won't output a @…). However, it conflicts with Parenscript code using ps:@ illegal…
Ehvince
  • 17,274
  • 7
  • 58
  • 79
0
votes
1 answer

Why does the Lisp reader return `(list 1 2 3)` instead of `(1 2 3)` when using reader macros?

Recently, I tried to understand reader macros better. I have read an article about using reader macros to read in objects in JSON format. With slightly adapted code from above article (it only reads (or is supposed to read) arrays [1,2,3] into lists…
nosejose
  • 3
  • 3
0
votes
1 answer

How do I use a reader macro directly in Racket?

I am trying to define a reader macro that reads the length of a string. The string will be enclosed in vertical bars (pipes). For example: |yes| -> 3 || -> 0 |The quick brown fox| -> 19 |\|| -> 1 — The pipe character can be escaped by preceding it…
Flux
  • 9,805
  • 5
  • 46
  • 92
0
votes
1 answer

What's the difference between set-macro-character and set-dispatch-macro-character?

From the signatures of these functions, the obvious difference is that set-macro-character allows you to set reader macro function for a single character, and set-dispatch-macro-character allows you to set it for any combination of two characters.…
OlegTheCat
  • 4,443
  • 16
  • 24
0
votes
1 answer

Is there a formal way of proposing/discussing changes to Clojure?

Is there a formal way of proposing/discussing changes to Clojure?
Mario
  • 6,572
  • 3
  • 42
  • 74
0
votes
1 answer

Creating a readtable with a disabled dispatch reader macro

I am creating a new language based on Racket and I don't want certain #x macros to work, such as the syntax-quote #'. How do I remove it so that #' does not do a syntax quote, but does whatever an unbound dispatch macro-char does? I can do that with…
user3286380
  • 574
  • 4
  • 10
0
votes
1 answer

How to set *readtable* to an empty one in common-lisp?

Standard common-lisp defines many reader macros such as ( and ) for grouping, ' for quote, " for string quotation, | for symbol quotation, # for dispatch macro, etc. Now I want to disable them all and use my own ones, and I have to call…
SaltyEgg
  • 1,498
  • 1
  • 15
  • 26
0
votes
2 answers

Reader macro debugging

Here's the situation: CL-USER> [bookid] # CL-USER> (sql-expression :attribute 'bookid) # CL-USER> [books.bookid] # CL-USER>…
BnMcGn
  • 1,440
  • 8
  • 22
1 2
3