Malabarba / names

A Namespace implementation for Emacs-Lisp
250 stars 19 forks source link

How to quote variable name? #21

Closed xuchunyang closed 9 years ago

xuchunyang commented 9 years ago

For example, I want to use foo- namespace for the code:

(defvar foo-history nil)
(read-string "> " nil 'foo-history)

I've tried

(define-namespace foo-

(defvar history nil)
(read-string "> " nil 'history)

)

'history can not expand to 'foo-history, I know it is expected, but how to make it expanded?

Malabarba commented 9 years ago

Yes, it is expected. It is impossible for Names to know for sure when 'history refers to a variable name and when it is just a symbol provided for some other purpose, so it errs on the side of caution. The correct thing to do here is simply to write the full name 'foo-history.

Alternatively, you can tell Names to expand the short names by adding the :assume-var-quote keyword to your namespace declaration. So it would look like:

(define-namespace foo- :assume-var-quote
;; Rest of code ...
)
xuchunyang commented 9 years ago

Well, use the full name now, thanks for your help.