Changeset 16078 in project


Ignore:
Timestamp:
09/25/09 02:52:52 (10 years ago)
Author:
Kon Lovett
Message:

Rel 2.0.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/procedure-decoration

    r16077 r16078  
    44== Introduction
    55
    6 {{Chicken Scheme}} procedures have attributes, aspects of the procedure object
     6Chicken Scheme procedures have attributes, aspects of the procedure object
    77that can be operated upon. Such an attribute is known as a "procedure decoration".
    88
    99This extension provides a facility to perform procedure decoration operations.
    10 
    11 
    12 == Usage
    13 
    14 (require-extension procedure-decoration)
    1510
    1611
     
    160155
    161156
     157== Usage
     158
     159<enscript language=scheme>
     160(require-extension procedure-decoration)
     161</enscript>
     162
     163
    162164== Examples
    163165
    164 Using a new define syntax (works for compiled or interpreted procedures).
    165 
    166 <enscript language=scheme>
    167 (use procedure-decoration)
    168 (use (srfi 89))
    169 
    170 ;; Procedure documentation string API
    171 (define-procedure-extender docstring procedure-documentation documented-procedure?)
    172 
    173 ;; Procedure documentation 'define' wrappers
    174 
    175 ; Common code helper
    176 (define-syntax define-doc-helper
    177   (syntax-rules ()
    178     ((_ ?defknd (?nam ?arg0 ...) ?docstr . ?body)
    179       (begin
    180         (?defknd (?nam ?arg0 ...) ?body)
    181         (set! (procedure-documentation ?nam) ?docstr)))
    182     ((_ ?defknd ?nam ?docstr . ?body)
    183       (define-doc-helper ?defknd (?nam) ?docstr ?body)) ) )
    184 
    185 ; Chicken 'define'
    186 (define-syntax define/doc
    187   (syntax-rules ()
    188     ((_ ?head ?docstr . ?body)
    189       (define-doc-helper define ?head ?docstr ?body)) ) )
    190 
    191 ; Chicken SRFI-89 'define*'
    192 (define-syntax define*/doc
    193   (syntax-rules ()
    194     ((_ ?head ?docstr . ?body)
    195       (define-doc-helper define* ?head ?docstr ?body)) ) )
    196 
    197 ;; Try it out
    198 
    199 (define/doc (foo . args) "procedure is foo" #t)
    200 
    201 (procedure-documentation foo) ;=> "procedure is foo"
    202 
    203 (define*/doc (h2 (key: k #f) a . r) "h2 is srfi-89 proc" (list a k r))
    204 
    205 (procedure-documentation h2) ;=> "h2 is srfi-89 proc"
    206 </enscript>
    207 
    208166
    209167== Notes
    210168
    211 The {{decorate-lambda}} interface decorated procedure is not the original
     169* The {{decorate-lambda}} interface decorated procedure is not the original
    212170procedure. Decorating procedure {{foo}} will not change the procedure
    213171object of {{foo}}, but return a new one.
    214172
    215 The {{procedure-decorator}} interface can rewrite the procedure object.
     173* The {{procedure-decorator}} interface can rewrite the procedure object.
    216174Decorating procedure {{foo}} with a {{REPLACE?}} {{procedure-decorator}} changes
    217175the procedure object of {{foo}}.
     
    223181
    224182
     183== Requirements
     184
     185[[check-errors]]
     186
     187
     188== Version history
     189
     190; 2.0.0 : Initial Chicken 4 release
     191
     192
    225193== License
    226194
    227 Copyright (c) 2008 Kon Lovett.  All rights reserved.
     195Copyright (c) 2009 Kon Lovett.  All rights reserved.
    228196
    229197Permission is hereby granted, free of charge, to any person obtaining a
     
    244212ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    245213OTHER DEALINGS IN THE SOFTWARE.
    246 
    247 
    248 == Requirements
    249 
    250 misc-extn
    251 
    252 
    253 == Version history
    254 
    255 ; 1.0 :
Note: See TracChangeset for help on using the changeset viewer.