by unwind · 8y ago · 0 comments
You cannot take sizeof a function, and you can't copy functions around, for instance. The address of a function is a value ("data"), but not the function itself.
But that only strengthens the point: language features are just abstractions we use to reason about data. One can always strip all the abstractions and end up working with raw bits.
If there's a useful way to think about certain kinds of data - it might be useful to codify that way as a language feature. Such as specialised error handling.
(let ((counter 0))
(lambda () (incf counter))
When we evaluate this we get a function. It contains the captured lexical environment. If we call that function, the captured counter variable mutates.Now suppose we had a copy-function library function. I would expect it that if we apply it to this function, we get an object which carries a duplicate of the lexical environment. This means it has its own instance of counter. If we call the original function, the copied function's counter stays the same and vice versa.
I don't remember seeing such a copy-function in any Lisp dialect; there isn't one in ANSI CL. It seems it might be useful, same as the ability to copy a structure or OOP object.
Conditional compilation is just a compatibility workaround to them.