diff options
author | Ludovic Courtès <ludo@gnu.org> | 2011-10-15 17:34:48 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2011-10-15 17:36:41 +0200 |
commit | 43e53d64ca34ef7dd6b7f135114c72c9b39b399e (patch) | |
tree | 1ce025b5687a705da34377186630f6984b16abea | |
parent | 7c42e426dcf621af0d375ef27d5144efaf33fef6 (diff) | |
download | guile-43e53d64ca34ef7dd6b7f135114c72c9b39b399e.tar.gz |
doc: Mention the partial evaluator next to `define-inlinable'.
* doc/ref/api-procedures.texi (Inlinable Procedures): Mention inlining
performed by the partial evaluator.
-rw-r--r-- | doc/ref/api-procedures.texi | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/ref/api-procedures.texi b/doc/ref/api-procedures.texi index 5c6d38024..f1861a54a 100644 --- a/doc/ref/api-procedures.texi +++ b/doc/ref/api-procedures.texi @@ -801,11 +801,31 @@ setter or an operator struct. @node Inlinable Procedures @subsection Inlinable Procedures +@cindex inlining +@cindex procedure inlining You can define an @dfn{inlinable procedure} by using @code{define-inlinable} instead of @code{define}. An inlinable procedure behaves the same as a regular procedure, but direct calls will result in the procedure body being inlined into the caller. +@cindex partial evaluator +Bear in mind that starting from version 2.0.3, Guile has a partial +evaluator that can inline the body of inner procedures when deemed +appropriate: + +@example +scheme@@(guile-user)> ,optimize (define (foo x) + (define (bar) (+ x 3)) + (* (bar) 2)) +$1 = (define foo + (lambda (#@{x 94@}#) (* (+ #@{x 94@}# 3) 2))) +@end example + +@noindent +The partial evaluator does not inline top-level bindings, though, so +this is a situation where you may find it interesting to use +@code{define-inlinable}. + Procedures defined with @code{define-inlinable} are @emph{always} inlined, at all direct call sites. This eliminates function call overhead at the expense of an increase in code size. Additionally, the |