Malabarba / names

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

Why is there a need to differentiate between functions and variables? #16

Closed mpontus closed 9 years ago

mpontus commented 9 years ago

Bruce, if you don't mind delving into some details, please explain the reason. Isn't it all a symbol after all?

Malabarba commented 9 years ago

Yes, it's all a symbol, but they're not the same thing. A symbol can be both, either, or neither. Elisp is not like Clojure, where the two are the same thing.

If we expand the name of a function where a symbol is being used as a variable (or vice versa), then we'd generate invalid code, so we need to watch out for that.

mpontus commented 9 years ago

Thank you for your reply.

Did I understand you correctly that without type checking, following case constitute invalid code?

(defvar foo "bar")
(define-namespace ns-
(defun foo ())
(defun baz () (print foo))) ;; => (void-variable baz-foo)
Malabarba commented 9 years ago

Yes, if Names didn't differentiate functions and variables, that's exactly what would happen. :-)