3 ms·
> That said, Common Lisp is weird. What I find particularly jarring is that functions and variables live in different namespaces: if you put a function into a v
by greenkey 6y ago
> That said, Common Lisp is weird. What I find particularly jarring is that functions and variables live in different namespaces: if you put a function into a variable, you can’t just use it like a function, you have to funcall it.
Unless I’m misunderstanding, the author sounds like a developer that’s primarily used JS. It’s really not abnormal to have to include parens after a method name in a language, which indicating that you are calling a function.
- blockmeifyoucan 6y agoI think you are misunderstanding. In common Lisp you can call a regular function defined with defun as (foo "something"), but if bar is a variable containing a fuction you have to use (funcall bar " something"). I agree that this is weird and confusing.
- kame3d 6y agoIsn't that the same thing as using function pointers in C? You need the * to access the function the variable points to.
- eigenspace 6y agoSure, this isn't that rare of a thing for languages, but it is increasingly rare to find people who think this is a good idea.
- oalae5niMiel7qu 6y agoNo you don't. You call the pointer itself. It points to the first instruction in the function. It's more like Ruby's method(:foo) and .call().
- shakow 6y ago> It’s really not abnormal to have to include parens after a method name in a language That's not what he means. Assuming some pseudocode with a more common syntax to prune the parentheses question, Common lisp is doing this: function f(x) { print(x) } let a = f funcall(a)(27) # prints 27 Whereas Scheme is doing this: function f(x) { print(x) } let a = f a(27) # also prints 27 This is the fundamental difference between so-called Lisp-1 and Lisp-2 families, depending on whether functions and variable share the same namespace or if they have to be “lifted” from one to another through funcall.