freenode/lisp - IRC Chatlog
Search
11:01:19
no-defun-allowed
FUNCALL may also take a function obtained through some other method and calls that, unlike the usual `(fn arg ...)` syntax.
11:03:14
gabbiel
no-defun-allowed: so does my method, my method is better, I still don't see why funcall is needed at all
11:03:43
jackdaniel
gabbiel: imagine fn has no function associated with the symbol, so you evaluate it, and it evaluates to fn2
11:03:59
jackdaniel
now imagine fn2 symbol has no function associated with it, so it is evaluated to fn
11:04:17
jackdaniel
we already know, that fn has no function associated with the symbol, so it evaluates to fn2
11:04:37
jackdaniel
we already know, that fn2 has no function associated with the symbol, so it evaluates to fn
11:05:13
jackdaniel
etc. another reason to always require function in function position is performance, application is much faster because you know the function at compilation time
11:06:12
jackdaniel
by application I mean "function application", not "application in other words a program"
11:07:54
jackdaniel
you can't tell if foo will be called, you need to know if the symbol has function associated with it
11:08:11
gabbiel
LdBeth: what do you mean symbol-function cannot retrieve the dynamiccaly bound function
11:16:18
gabbiel
LdBeth: is that why sometimes I have to use #'symbol instead of 'symbol when using flet or labels?
11:18:16
gabbiel
oh yeah, can somebody explain inlining to me, somebody said I should inline this function
11:19:59
LdBeth
If a function is short or it is only defined for structuring program it worth to inline it
11:21:05
ck_
inlining means not placing the function call onto that stack, but (at compile time) 'inlining' the function into the procedure that calls it
11:21:05
no-defun-allowed
Basically, inlining substitutes the function body in where the function call goes.
11:21:58
no-defun-allowed
You lose some debugger information and the ability to update the function, but you avoid any function-calling overhead and possibly gain some more compiler optimisation, since it gets more context.
11:22:50
shrdlu68
gabbiel: Function calls have an overhead. Inlining functions eliminates that overhead.
11:23:19
no-defun-allowed
You could implement some kind of inlining with macros, but it's quite silly and function inlining gives you your usual function-call semantics without any headaches.
11:23:51
no-defun-allowed
Like how in C you'd write #define max(x, y) ((x) > (y) ? (x) : (y)) and then max(x++,y) would go horridly wrong.