-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathveracious-lambda.lisp
More file actions
34 lines (28 loc) · 887 Bytes
/
veracious-lambda.lisp
File metadata and controls
34 lines (28 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(defpackage :veracious-lambda
(:use :cl)
(:export
:enable
:disable
:vl-readtable))
(in-package :veracious-lambda)
(defun whitespacep (char)
(some (lambda (whitespace) (char= char whitespace))
'(#\Newline #\Space #\Tab #\Page #\Return)))
(defun lambda-reader (stream char)
(declare (ignore char))
(let ((next (peek-char nil stream nil nil t)))
(if (or (null next)
(whitespacep next)
(and (get-macro-character next)
(not (char= next #\λ))))
'lambda
(with-standard-io-syntax
(read-from-string (format nil "λ~S" (read stream t nil t)))))))
(named-readtables:defreadtable vl-readtable
(:merge :standard)
(:case :upcase)
(:macro-char #\λ #'lambda-reader t))
(defun enable ()
(named-readtables:in-readtable vl-readtable))
(defun disable ()
(named-readtables:in-readtable :standard))