MacroPackage: exclToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version

def-fwrapper

Arguments: name arglist &body body

Produces a form which returns name and defines an fwrapper as a side effect. This fwrapper is suitable for use as the fwrap-function in a call to fwrap.

name can be any function spec.

arglist is an ordinary lambda list. All ordinary lambda list keywords may be used, including &allow-other-keys, &aux, &key, &optional, and &rest. If either &key or &rest are present, then the arglist is automatically forced to be a list. (Note: the current implementation also forces a list when optional arguments are specified, because of some potential problems when a not-given optional argument is setq'd).

Argument accesses are provided for by means of symbol-macrolets, in a manner that is mostly intuitive. The arguments can simply be accessed by name, and they can be setq'd under most circumstances, with exceptions given below. The values of these setq'd arguments become part of the argument list that is sent to the next more inner fwrapper.

Exceptions:

def-fwrapper is a defining macro like defun

def-fwrapper is a additional defining macro in Allegro CL, joining the standard defining macros like defun. Among other things, this means that the resulting code is wrapped in a block named by the wrapper name which can be returned from. As with any defining macro, one can use macroexpand and pprint to see what is actually happening (you may see a different macroexpansion -- this is shown only to see how to get a macroexpansion):

CL-USER(1): (pprint (macroexpand '(def-fwrapper foo (a b) nil)))

(PROGN (EVAL-WHEN (COMPILE)
         (EXCL::CHECK-LOCK-DEFINITIONS-COMPILE-TIME 'FOO 'FUNCTION
           'DEF-FWRAPPER (FBOUNDP 'FOO)))
       (SETF (FDEFINITION 'FOO)
             (NAMED-FUNCTION FOO
               (LAMBDA (EXCL::NEXT-FWRAPPERS EXCL::FWRAP-ENV
                        EXCL::PRIMARY-FUNCTION ARGLIST EXCL::NARGS)
                 (DECLARE
                  (IGNORABLE EXCL::NEXT-FWRAPPERS EXCL::FWRAP-ENV
                   EXCL::PRIMARY-FUNCTION))
                 (EXCL::FWRAPPER-ARGUMENT-CHECK 'FOO 2 2 ARGLIST
                   EXCL::NARGS)
                 (BLOCK FOO
                   (SYMBOL-MACROLET ((A
                                      (EXCL::GET-FWRAPPER-ARG
                                       EXCL::NARGS
                                       0
                                       ARGLIST))
                                     (B
                                      (EXCL::GET-FWRAPPER-ARG
                                       EXCL::NARGS
                                       1
                                       ARGLIST)))
                     (LET* ()
                       (LET* ((#:G4 NIL))
                         (DECLARE (IGNORABLE #:G4))
                         NIL)))))))
       (REMPROP 'FOO 'EXCL::%FUN-DOCUMENTATION)
       (RECORD-SOURCE-FILE 'FOO) 'FOO)
CL-USER(2): 

See fwrappers-and-advice.htm for information of fwrapping functions (and on the older, deprecated advice facility).


Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 9.0
Unrevised from 8.2 to 9.0.
8.2 version