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
18
votes
7 answers

Read macros: what do you use them for?

I'm trying to get a feel for the parts of Lisp that I haven't used very much up to now. Read macros have caught my attention at the moment. There isn't a huge amount of info about their use and it would help to see what people have done with them,…
Pinochle
  • 5,515
  • 2
  • 26
  • 20
15
votes
3 answers

What advantage does common lisp reader macros have that Clojure does not have?

I have been using Clojure alot recently but I still don't understand what functionality I do not get that common lisp reader macros provide. Can explain explain this to me in simple terms?
yazz.com
  • 57,320
  • 66
  • 234
  • 385
10
votes
2 answers

operator #+ and #- in .sbclrc

Anybody know what #+ and #- operators means in .sbclrc? I couldn't find it in the manual. I see #- in .sbclrc after I installed quicklisp: #-quicklisp (let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" …
sudo
  • 647
  • 2
  • 7
  • 19
8
votes
2 answers

Differences between Sharpsign Colon and Gensym

I've just been reading up on the sharpsign colon reader macro and it sounded like it had a very similar effect to gensym Sharpsign Colon: "introduces an uninterned symbol" Gensym: "Creates and returns a fresh, uninterned symbol" So a simple…
Baggers
  • 3,183
  • 20
  • 31
7
votes
2 answers

What's the meaning of "#+" in the code of cl-mysql?

Recently I tried to read code about cl-mysql, but got stuck with the #+. Tried to google it, but not work, so turn to here (defun make-lock (name) #+sb-thread (sb-thread:make-mutex :name name) #+ecl (mp:make-lock :name name) #+armedbear…
c0rehe110
  • 81
  • 3
7
votes
3 answers

Common lisp: is there a less painful way to input math expressions?

I enjoy common lisp, but sometimes it is really painful to input simple math expressions like a(8b^2+1)+4bc(4b^2+1) (Sure I can convert this, but it is kind of slow, I write (+ () ()) first, and then in each bracket I put (* () ())...) I'm…
h__
  • 865
  • 1
  • 11
  • 19
7
votes
3 answers

Compiling Lisp code with read macros

I'm having a bit of trouble understanding what becomes of read macros when compiling a file of lisp code into a bytecode or raw assembly (or a fasl file for that matter). Or maybe I do understand it but don't know. I'm just really confused. When you…
Seth Carnegie
  • 73,875
  • 22
  • 181
  • 249
6
votes
2 answers

Why does Clojure lack user defined reader macros?

As I understand it Clojure does not expose the reader macro table or allow user defined reader macros. From http://clojure.org/reader: The read table is currently not accessible to user programs. I'm just wondering if there is a definitive or…
Paul
  • 3,009
  • 16
  • 33
6
votes
1 answer

How to eval Lisp code inside a reader macro?

I'm writing my own x86-64 assembler in Common Lisp and it produces correct binary code for a subset of x86-64. I use a custom reader macro to convert assembly code to a syntax tree, and it works as expected. What I am attempting to accomplish is to…
nrz
  • 10,435
  • 4
  • 39
  • 71
6
votes
2 answers

Why don't reader macro extensions propagate to runtime (read)?

Why does the following not work? ;;;; foo.lisp (in-package :cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) (require :cl-interpol)) (cl-interpol:enable-interpol-syntax) (defun read-and-eval (s) (eval (read-from-string…
nbtrap
  • 581
  • 2
  • 12
5
votes
2 answers

What is the meaning of #+: and #-: in common lisp

I am reading the cl-fad/load.lisp code tonight, and I found there are symbols #+: and #-: in the front of expression or string. What's these symbols meaning?
ccQpein
  • 705
  • 7
  • 20
5
votes
1 answer

Backquote in Common Lisp: read and eval

This question is somewhat replated to this and this for Elisp. Basically, how is the back-quote read and evaluated? What processes are happening? And does the standard say anything about it? Here is what I would expect, but it doesn't happen: symbol…
mobiuseng
  • 2,326
  • 1
  • 16
  • 30
5
votes
4 answers

Is there an if-clojurescript macro?

Is there a macro for Clojure and ClojureScript that would allow you to insert different expressions depending on whether the file is being compiled in Clojure or Clojurescript? (if-clojurescript (my clojurescript definition) (my clojure…
Rob Lachlan
  • 14,289
  • 5
  • 49
  • 99
5
votes
1 answer

Define my own read macro

There are some read macros in Common Lisp such as ' #' #P, but how can I write a read macro? Like this: #T"hello world" ====================> (gettext "hello world")
Mike Manilone
  • 582
  • 4
  • 17
4
votes
1 answer

Common Lisp Hash-Dot #. Reader Macro

Recently, I have come across the so-called hash-dot Common Lisp reader macro and am wondering how it works and what it does. Using search engines was not of much help, so any examples, explanations and especially uses-cases are most welcome.
MadPhysicist
  • 5,401
  • 11
  • 42
  • 107
1
2 3