Elektrine lite

← Feed

@kentpitman@climatejustice.social

2026-09-19 07:03 UTC

@vnikolov@ieji.de @pascal_costanza@functional.cafe @screwlisp@gamerplus.org @ramin_hal9001@fe.disroot.org @SDF@mastodon.sdf.org (This returns to the topic of defwhopper semantics. Brewster and IA removed, as they probably don't care about this thread beyond my last message.) Here is the example from the links I offered in the previous message: ========== Examples of Whoppers The following whopper adds code around the execution of the method that performs the generic function print-integer on instances of the foo flavor. Specifically, the whopper binds the value of the special variable base to 3 around the execution of the method. This function takes one argument, n: (defwhopper (print-integer foo) (n) (let ((base 3)) (continue-whopper n))) The following whopper sets up a catch around the execution of the compute-height method of flavor giant, regardless of what arguments this methods accepts: (defwhopper (compute-height giant) (&rest args) (catch ’too-high (lexpr-continue-whopper args))) ========== And this information may be helpful as well: ========== Summary of Functions Related to Wrappers and Whoppers defwrapper (generic-function flavor) (arglist &rest combined-method-body) &body body Defines a wrapper. defwhopper (generic-function flavor) arglist &body body Defines a whopper. continue-whopper &rest args Calls the methods for the generic function that was intercepted by the whopper. This is intended for use in defwhopper forms. lexpr-continue-whopper &rest args Like continue-whopper, but the last argument should be a list of arguments to be passed. This is useful when the arguments to the intercepted generic function include an &rest argument. defwhopper-subst (generic-function flavor) arglist &body body Defines a wrapper by combining the convenient syntax of defwhopper with the efficiency of defwrapper. ========== EDIT: I should have said the source of this and related concept information is: https://web.archive.org/web/20191013221848/https://doc.lagout.org/science/0_Computer%20Science/0_Computer%20History/old-hardware/symbolics/software/genera_8/Symbolics_Common_Lisp_Programming_Constructs.pdf (pages 621-624)

Replies (1)

  • @vnikolov@ieji.de 2026-09-19 07:19

    Kent, thank you again. This is quite instructive, including at the metalevel: showing how the language evolved and offering a (simple) mental exercise of translating those examples into CLOS. I should study more the subject of declaring generic functions and methods inline. @kentpitman@climatejustice.social @pascal_costanza@functional.cafe @screwlisp@gamerplus.org @ramin_hal9001@fe.disroot.org @SDF@mastodon.sdf.org

    Open ##4760484