sbcl - Evolving a lisp image -
i love idea of image-based languages, , lately i've been toying common lisp via sbcl. i've read in few places how through being able save , load image of virtual machine, can evolve application or set of apps running on image.
i how load code image , running, slime makes sort of thing nice, question this: how can tell functions defined in image? let's want make update function days or months after has been running , can't remember name. there way code or names of functions defined in image?
now, write code out source , load in via repl, have copy there, seems obvious feature.
common lisp has idea of packages. packages kind of registry symbols , used namespaces symbols. can ask common lisp list of packages.
cl-user 1 > (list-all-packages) (#<the sql-common package, 0/4 internal, 28/32 external> #<the loop package, 245/256 internal, 3/4 external> #<the comm package, 0/4 internal, 940/1024 external> #<the reg package, 41/64 internal, 0/4 external> ...)
each packages stores interned symbols in data structure. can ask common lisp symbols interned in package.
cl-user 2 > (loop symbol being each external-symbol in (find-package "common-lisp") collect symbol) (make-array invoke-debugger string-trim ...)
to make easier, common lisp provides functions apropos , apropos-list.
cl-user 3 > (apropos "make-lock") mp::internal-make-lock (defined) mp:make-lock (defined) www-utils:make-lock (defined) make-lock resources::make-lock (defined) miniproc:make-lock (defined)
functions, classes, etc. use symbols identifier. can ask symbol, function denotes.
cl-user 4 > (symbol-function 'www-utils:make-lock) #<function www-utils:make-lock 41e006a69c>
sometimes common lisp records definition of functions. function function-lambda-expression can used retrieve 'it'.
cl-user 5 > (defun foo (a) (* (sin a) a)) foo cl-user 6 > (pprint (function-lambda-expression 'foo)) (lambda (a) (declare (system::source-level #<eq hash table{0} 41403151c3>)) (declare (lambda-name foo)) (* (sin a) a))
but nowadays common lisp implementations don't use recorded definitions, record locations of source each lisp construct.
most common lisp implementations can track source locations in implementation specific way.
the common lisp standard defines function ed.
cl-user 7 > (ed 'www-utils:make-lock)
this calls editor (internal or external) , should open source code function. make work, common lisp needs keep track of source location each function. next editor needs have access source. location recorded absolute path /users/joswig/lisp/utils.lisp . if editor wants open file, should accessible. possible use logical pathnames http:server;utils.lisp . translated real physical pathname. translation can later configured. possible move lisp different machine different pathnames, configure logical pathname http , lisp still finds source code, though on different machine different file system structure. so, make work may need configuration. useful feature , used.
how recording of source code , how recording of source locations work implementation dependent , feature of respective lisp in combination development environment. better lisp implementations have lot of features in area.
Comments
Post a Comment