4 ms·
Although Common Lisp is called Lisp-2, there are actually many more namespaces... I think I counted 5 or 6 the last time I tried. But it is pretty sensible to
by giantdude 4y ago
Although Common Lisp is called Lisp-2, there are actually many more namespaces... I think I counted 5 or 6 the last time I tried. But it is pretty sensible to keep functions in a different namespace. For instance, it allows you to:
(let ((let '`(let ((let ',let))
,let)))
`(let ((let ',let)) ,let))
- AnimalMuppet 4y agoThat's sensible? I do not think that word means what you think it means... I mean, yes, having functions in a different namespace may be sensible, or at least defensible. That example is ridiculous.
- Jtsummers 4y agoIt's like `make make make make`. But it is nice that in CL you don't have to jump through hoops on common words that happen to be function or package names. You have a list and no meaningful name? Call it `list`: (defun some-algo (list ...) ...) Sure you can abuse this, everything can be abused. But I'd rather risk an asshole doing that `let` thing (which wouldn't make it past code review) than have more name collisions and naming contortions to avoid them. If the language at least warned on renaming it would be helpful, but then you get things like Go. When I was learning it I accidentally overwrote some built-in function (I don't recall which one, it wasn't actually `make` like in this demo): package main func main () { make := 10 aMap := make(map[int]string) // this is now an error } I wish I could remember what it was, it was a reasonable name in context (unlike `make` above). But it had a similar effect and a similar strange error. The error is at the function call site, which is technically correct because you're trying to use an `int` (here) as a function. But `make` (above) and similar functions should probably get a warning emitted when you redefine them, at a minimum.
- dwringer 4y agoIf Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo, might as well let let let let let. In seriousness I like the ability to make such distinctions even if it can be a huge footgun.
- giantdude 4y agoIn practice it is not a footgun at all! If you use Lisp, you can tell what's a function and what's a variable by position - functions are always first in a list, variables - never, (except in bindings)... etc.
- giantdude 4y agoThere is this thing we call humor. Try running the example!