4 ms·
From the Lips's perspective it is a contradiction. Something is either a function or a constant. The logic is that this object could be called as a function an
by dschiptsov 14y ago
From the Lips's perspective it is a contradiction. Something is either a function or a constant.
The logic is that this object could be called as a function and at the same time always evaluated to itself?
That means whenever you call it you always getting it back - this is behavior of a constant. But if you could call it with an argument, you will get back some value, different from whatever it is?
As long as maps are immutable, it will behave as a function - return the same value for the same argument.
OK, but, please, don't tell me that this isn't confusing.)
- chc 14y ago> That means whenever you call it you always getting it back - this is behavior of a constant. No! You're confusing functions-as-callable-things and functions-as-values. The phrase "a constant" does not generally imply anything about a thing's behavior when called. It just means something whose value will never change. A self-evaluating constant is a constant that circularly evaluates to itself — nothing else can have that value without referring to the constant. But neither of these things have to do with calling anything; they're just about taking values. A constant can certainly refer to a function that returns something other than that constant. For example, in Ruby: `Example = lambda { 1 }`. If you just evaluate "Example", you will get a Proc value, but if you call Example, you will get the Fixnum 1. In most languages that have them, you cannot call a self-evaluating constant. It won't return itself — it's just not a callable thing. In Clojure, keywords are self-evaluating constants that have the behavior of looking themselves up as a key in the argument when called. They serve the purpose of self-evaluating constants exactly the same as in other languages, but they also have the handy property of doing map lookups.
- baar 14y agoGood explanation! Evaluation is what happens when you give something as a parameter. Calling is what happens when you do "(f ...)". Just a little concrete example: Welcome to Racket v5.3.1. > 'foo 'foo > ('foo) application: not a procedure; expected a procedure that can be applied to arguments given: 'foo arguments...: [none] context...: /usr/lib/racket/collects/racket/private/misc.rkt:87:7
- chc 14y ago@baar: FYI, you appear to be hellbanned (your comments are being automatically killed as soon as you post them). New accounts are particularly susceptible to this, as it seems like the auto-ban algorithm kicks in when you have low karma and get too many downvotes in a short time, or something like that. You should be OK if you make a new account and avoid making very harsh comments so you don't draw downvotes.
- baar 14y ago(Just in case you can see this:) Thanks for letting me know. I'd figured as much (from browsing anonymously) -- I guess the powers that be don't care enough to get new commenters. Oh well. I won't bother to create a new account; I really shouldn't wasting time posting here anyway.