Description

Call arbitrary values as functions

Author

Felix L. Winkelmann

Version

Usage

(require-extension object-apply)

Download

object-apply.egg

Documentation

This extension allows user-defined behaviour of calling non-procedural data. When a procedure-call is evaluated with a datum in operator position that is not a procedure, then the following TinyCLOS generic function is called:

generic: (object-apply OPERATOR ARGUMENTS)

Called when OPERATOR was applied to the argument list ARGUMENTS. The default implementation specialized on the operator class <top> signals an error. Implement own specializations for this generic to get custom behaviour.

This hook will not be called in code compiled in unsafe mode.

Examples

; Regular expressions in operator position do a string-match:

(define-method (object-apply (x <regexp>) args) 
  (apply string-match x args) )

((regexp "([A-Z]+).*") "ABC, def")

License

Copyright (c) 2006, Felix L. Winkelmann.  All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the Software),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.