3 ms·
So I am no stranger to CL, but the problem solved in the article isn't actually one that's solved by evaluating less than the whole file at once, and in fact I
by suskeyhose 4y ago
So I am no stranger to CL, but the problem solved in the article isn't actually one that's solved by evaluating less than the whole file at once, and in fact I didn't tell anyone to re-evaluate the whole file at all in this article.
The critical idea here is it applies to long-running functions, like a loop, a server, or other things. These, when handed function objects, will not reflect new behavior if you re-evaluate a single function.
The article solves for this by explaining to intermediate programmers that there is a difference between using function objects and using vars, something that Common Lisp programmers learn too by using #' to retrieve function objects and passing symbols and using symbol-function to look up the associated function as needed.
- dmux 4y ago>The critical idea here is it applies to long-running functions, like a loop, a server, or other things. These, when handed function objects, will not reflect new behavior if you re-evaluate a single function. Do you mind going into more details about what you mean here? In my experience, recursive loops will pick up a new function definition but non-recursive loops will only pick up the definition of a function upon entry.
- suskeyhose 4y agoThe idea is such a long lasting loop would take the function object as an argument and call it repeatedly. Recursive or not (tho in clojure's case definitely not, no tail call optimization), doesn't matter as the lookup happened at the first function call.
- lispm 4y agoCL: in a primitive way this can be done with generic functions. Use a generic function object. Redefined methods will be picked up without needing a new function object. When using symbols, often it is not needed to look up symbol functions. Symbols can be called as functions. In code Lisp often assumes that functions are late bound (unless inlined), so a function call to a global function looks up the function from the symbol at runtime.
- suskeyhose 4y agoThis is kinda my point tho, CL's symbols are the same as Clojure's vars for this purpose. And the comparison between generic functions and multimethods is obvious and correct here as well. Late binding is irrelevant because all of this is about functions as arguments, not in funcall position.