stream - Change default reader in common lisp -


i wrote function replace function read of common lisp

(defun my-read (stream &rest args)   (declare (ignore args))   (funcall (my-get-macro-character (read-char stream)))) 

is there way use function default reader?

you can't redefine built in functions1, can define package shadows cl:read , defines new function my:read, when use package, looks like it's default read function. e.g., this:

cl-user> (defpackage #:my-package             (:use "common-lisp")            (:shadow #:read)            (:export #:read)) ;=> #<package "my-package">  cl-user> (defun my-package:read (&rest args)            (declare (ignore args))            42) ;=> my-package:read  cl-user> (defpackage #:another-package            (:use #:my-package "common-lisp")            (:shadowing-import-from #:my-package #:read)) ;=> #<package "another-package">  cl-user> (in-package #:another-package) ;=> #<package "another-package">  another-package> (read) ;=> 42 

  1. actually, rainer joswig noted in comments, though it's undefined behavior (see 11.1.2.1.2 constraints on common-lisp package conforming programs), there are ways redefine of common lisp function, instance, in sbcl can use unlock-package, shown in redefining built-in function. clisp has package locks. other implementations may have similar functionality.

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -