3 ms·
>If I have a function to compute a user’s age based on their birthdate, it is called age, not calculate-age or get-age. Ah, but isn't Clojure Lisp-1? Then you
by Grue3 11y ago
>If I have a function to compute a user’s age based on their birthdate, it is called age, not calculate-age or get-age.
Ah, but isn't Clojure Lisp-1? Then you can't have function `age` and variable `age` in the same scope despite `age` being a great variable name in many circumstances. Hence having to come up with silly variable names like "lst" instead of "list", because all the good names are taken by the functions.
- mapleoin 11y agoHe discusses that in a later pargraph "Local name clashes", basically advocating the use of namespace prefixes.
- astine 11y agoWhen I write Clojure I tend not to worry too much about this. Most of my variable names will be declared with `let` and will have a very limited scope. I can go ahead and clash some builtin function name and not worry about it unless I happen to need that builtin function within the `let` block. It usually is the case that I don't need to.
- Grue3 11y agoLocally overriding builtin/global functions seems like a bug waiting to happen. There's no way to figure out if you actually intended to use the local variable inside of scope, or the function it overshadowed. It seems to me that in Lisp-1 all local variables should be prefixed with some sort of symbol so that they can never override globals.