Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In most implementations, redefining an inline function or macro just means you may have some callers using the old code. SBCL warns if you redefine an inline function but doesn’t re-compile old code. Do note that the language has a different view on the matter though.

In its list of assumptions compilers are allowed to make about the code they receive, we can see…

> The definition of a function that is defined and declared inline in the compilation environment must be the same at run time.

> Within a function named F, the compiler may (but is not required to) assume that an apparent recursive call to a function named F refers to the same definition of F, unless that function has been declared notinline. The consequences of redefining such a recursively defined function F while it is executing are undefined.

> A call within a file to a named function that is defined in the same file refers to that function, unless that function has been declared notinline. The consequences are unspecified if functions are redefined individually at run time or multiply defined in the same file.

http://clhs.lisp.se/Body/03_bbc.htm

So, technically the compiler is allowed to remove runtime function call indirection for functions defined in the same file and/or recursive calls (unless you use a NOTINLINE declaration). In practice, you probably won’t see that happen unless you crank up the optimizations when compiling.

You are right that the language explicitly allows redefining functions in general

> Except in the situations explicitly listed above, a function defined in the evaluation environment is permitted to have a different definition or a different signature at run time, and the run-time definition prevails.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: