I tried to determine if Emacs returned object by reference or value, but could not find a clear answer (searching google and Emacs Lisp manual). I guess it must be "by reference", and I just overlooked it somewhere..

For example:

(defun my-get-hash ()
  (let ((h (make-hash-table :test 'equal)))
    (puthash "a" 1 h)

(let ((h2 (my-get-hash)))
  (message (prin1-to-string h2)))

Here the hash h is created with a let binding, and then return to the caller. Does the caller receive a reference or a copy of h?

1 Answer 1


It's by reference when it comes to complex types like vectors and lists (or, more correct, cons pairs).

Simple types like symbols and numbers are not mutable, so they can be seen as "by value".

  • 6
    Thanks. It would be nice to have a link/reference to the documentation where this is stated.. Feb 6, 2015 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.