Serializing in Lisp


/ Published in: Lisp
Save to your folder(s)

Example of serializing a lisp variable.


Copy this code and paste it in your HTML
  1. ;;; Save
  2. (defun save-obj (filename obj)
  3. (with-open-file (out filename
  4. :direction :output
  5. :if-exists :supersede)
  6. (with-standard-io-syntax
  7. (print obj out))))
  8.  
  9. ;;; Load
  10. (defun load-obj (filename obj)
  11. (with-open-file (in filename)
  12. (with-standard-io-syntax
  13. (setf obj (read in)))))

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.