Changeset 16020 in project


Ignore:
Timestamp:
09/21/09 20:48:26 (10 years ago)
Author:
Kon Lovett
Message:

Rel 1.6.0 of check-errors. Rel 1.1.0 of coerce

Location:
wiki/eggref/4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/check-errors

    r15996 r16020  
    9191<procedure>(check-structure LOCATION OBJECT TAG [ARGUMENT-NAME])</procedure>
    9292
     93{{check-record}} and {{check-record-type}} are essentially synonyms.
     94
    9395==== check-symbol
    9496
     
    122124
    123125<procedure>(check-argument-count LOCATION ARGC MAXARGC)</procedure>
     126
     127==== check-open-interval
     128
     129<procedure>(check-open-interval LOCATION NUM MINNUM MAXNUM)</procedure>
     130
     131{{NUM}} in {{]MINNUM MAXNUM[}}.
     132
     133==== check-closed-interval
     134
     135<procedure>(check-closed-interval LOCATION NUM MINNUM MAXNUM)</procedure>
     136
     137{{NUM}} in {{[MINNUM MAXNUM]}}.
     138
     139==== check-half-open-interval
     140
     141<procedure>(check-half-open-interval LOCATION NUM MINNUM MAXNUM)</procedure>
     142
     143{{NUM}} in {{]MINNUM MAXNUM]}}.
     144
     145==== check-half-closed-interval
     146
     147<procedure>(check-half-closed-interval LOCATION NUM MINNUM MAXNUM)</procedure>
     148
     149{{NUM}} in {{[MINNUM MAXNUM[}}.
    124150
    125151==== define-check-type
     
    268294<procedure>(error-structure LOCATION OBJECT TAG [ARGUMENT-NAME])</procedure>
    269295
     296{{error-record}} and {{error-record-type}} are essentially synonyms.
     297
    270298==== error-symbol
    271299
     
    299327
    300328<procedure>(error-argument-count LOCATION ARGC MAXARGC)</procedure>
     329
     330==== error-open-interval
     331
     332<procedure>(error-open-interval LOCATION NUM MINNUM MAXNUM)</procedure>
     333
     334==== error-closed-interval
     335
     336<procedure>(error-closed-interval LOCATION NUM MINNUM MAXNUM)</procedure>
     337
     338==== error-half-open-interval
     339
     340<procedure>(error-half-open-interval LOCATION NUM MINNUM MAXNUM)</procedure>
     341
     342==== error-half-closed-interval
     343
     344<procedure>(error-half-closed-interval LOCATION NUM MINNUM MAXNUM)</procedure>
    301345
    302346==== define-error-type
     
    413457== Version history
    414458
     459; 1.6.0 : Added interval support.
    415460; 1.5.0 : Added alist and argument count support.
    416461; 1.4.0 :
  • wiki/eggref/4/coerce

    r16003 r16020  
    1515The major difference here is the ability to extend the type domain.
    1616
     17{{TYPE-TAG}} is a {{symbol}}.
     18
     19{{TYPE-PRED}} is a procedure, {{(object -> boolean)}}, testing whether the
     20argument is a type.
     21
    1722=== type-of
    1823
     
    2833==== type-of
    2934
    30 <procedure>(type-of OBJECT)</procedure>
    31 
    32 Returns a type symbol for the type of {{OBJECT}}.
    33 
    34 Built-in types are {{unspecified}} ({{void}}), {{boolean}},
    35 {{record-instance}}, {{port}}, {{char}}, {{number}}, {{string}}, {{keyword}},
    36 {{symbol}}, {{pair}}, {{list}}, and {{vector}}. The catch-all is
    37 {{scheme-object}}.
     35<procedure>(type-of OBJECT) => TYPE-TAG</procedure>
     36
     37Returns a type tag for the type of {{OBJECT}}.
     38
     39Built-in type tags are {{unspecified}} ({{void}}), {{boolean}}, {{port}},
     40{{char}}, {{number}}, {{string}}, {{keyword}}, {{symbol}}, {{pair}}, {{list}},
     41{{blob}}, {{procedure}}, {{pointer}}, {{locative}}, and {{vector}}. A
     42{{record-instance}} type tag is the {{record-instance-tag}}. The catch-all
     43is {{object}}.
    3844
    3945==== type-of-extended?
    4046
    41 <procedure>(type-of-extended? TYPE-SYMBOL)</procedure>
    42 
    43 Is the domain extended to cover the type identifier {{TYPE-SYMBOL}}.
     47<procedure>(type-of-extended? TYPE-TAG) => BOOLEAN</procedure>
     48
     49Is the domain extended to cover the type identifier {{TYPE-TAG}}.
    4450
    4551==== type-of-extend!
    4652
    47 <procedure>(type-of-extend! TYPE-SYMBOL PREDICATE)</procedure>
    48 
    49 Extends the domain of type-of with the type definition {{(TYPE-SYMBOL
    50 PREDICATE)}}.
    51 
    52 {{PREDICATE}} is a procedure, {{(object -> boolean)}}, testing whether the
    53 argument is a type.
     53<procedure>(type-of-extend! TYPE-TAG TYPE-PRED)</procedure>
     54
     55Extends the domain of type-of with the type definition {{(TYPE-TAG
     56TYPE-PRED)}}.
    5457
    5558==== type-of-composite-extension!
    5659
    57 <procedure>(type-of-composite-extension! TYPE-SYMBOL PREDICATE)</procedure>
     60<procedure>(type-of-composite-extension! TYPE-TAG TYPE-PRED)</procedure>
    5861
    5962Extends the domain of an existing type-of extension.
    6063
    61 {{TYPE-SYMBOL}} and {{PREDICATE}} are as for {{extend-type-of}}.
    62 
    63 Should the new {{PREDICATE}} and existing predicate be {{eq?}} the
     64Should the new {{TYPE-PRED}} and existing TYPE-PRED be {{eq?}} the
    6465operation is ignored.
    6566
    6667==== type-of-extension-remove!
    6768
    68 <procedure>(type-of-extension-remove! TYPE-SYMBOL)</procedure>
    69 
    70 Delete any existing type-of extension for {{TYPE-SYMBOL}}.
     69<procedure>(type-of-extension-remove! TYPE-TAG)</procedure>
     70
     71Delete any existing type-of extension for {{TYPE-TAG}}.
    7172
    7273=== coerce
     
    8384==== coerce
    8485
    85 <procedure>(coerce OBJECT TYPE-SYMBOL [DEFAULT-PROC])</procedure>
    86 
    87 Converts {{OBJECT}} to a value of {{TYPE-SYMBOL}}.
    88 
    89 {{DEFAULT-PROC}} is a procedure with the signature {{(OBJECT TYPE-SYMBOL ->
     86<procedure>(coerce OBJECT TYPE-TAG [DEFAULT-PROC]) => OBJECT</procedure>
     87
     88Converts {{OBJECT}} to a value of {{TYPE-TAG}}.
     89
     90{{DEFAULT-PROC}} is a procedure with the signature {{(OBJECT TYPE-TAG ->
    9091OBJECT)}} and is invoked when coercion fails. The default is to signal an
    9192error.
    9293
    93 Built-in types are {{boolean}},
    94 {{record-instance}}, {{port}}, {{char}}, {{number}}, {{string}}, {{keyword}},
    95 {{symbol}}, {{pair}}, {{list}}, and {{vector}}.
     94Built-in types are {{boolean}}, {{port}}, {{char}}, {{number}}, {{string}}, {{keyword}},
     95{{symbol}}, {{pair}}, {{blob}}, {{list}}, and {{vector}}.
    9696
    9797==== coerce-all
    9898
    99 <procedure>(coerce-all (OBJECT...) (TYPE-SYMBOL...) [DEFAULT-PROC])</procedure>
     99<procedure>(coerce-all (OBJECT...) (TYPE-TAG...) [DEFAULT-PROC]) => LIST</procedure>
    100100
    101101Returns a list of every element of the {{(OBJECT...)}} coerced to the
    102 corresponding element of the {{(TYPE-SYMBOL...)}}.
    103 
    104 {{DEFAULT-PROC}} and {{TYPE-SYMBOL}} are as for {{coerce}}.
     102corresponding element of the {{(TYPE-TAG...)}}.
     103
     104{{DEFAULT-PROC}} is as for {{coerce}}.
    105105
    106106==== make-case-coerce
    107107
    108 <procedure>(make-case-coerce CONVERTOR [ALIST])</procedure>
     108<procedure>(make-case-coerce CONVERTOR [ALIST]) => PROCEDURE</procedure>
    109109
    110110Returns a coercion procedure for use with {{extend-coerce}}
    111111
    112 {{CONVERTOR}} is a coercion procedure, {{(object symbol on-error -> object)}}.
    113 
    114 {{ALIST}} is a list of {{(type-symbol . (object -> object)}}.
     112{{CONVERTOR}} is a coercion procedure with the signature {{(OBJECT TYPE-TAG
     113ON-ERROR -> object)}}. {{ON-ERROR}} is a procedure/0 that is invoked when all
     114else fails.
     115
     116{{ALIST}} here is a list of {{(TYPE-TAG . (OBJECT -> OBJECT)}}.
    115117
    116118==== case-coerce
    117119
    118 <macro>(case-coerce CASE ...)</macro>
     120<macro>(case-coerce CASE ...) => PROCEDURE</macro>
    119121
    120122Returns a coercion procedure for use with {{extend-coerce}}.
    121123
    122 {{CASE}} is of the form {{((TYPE-SYMBOL ...) EXPRESSION ...)}}, or {{(else
     124{{CASE}} is of the form {{((TYPE-TAG ...) EXPRESSION ...)}}, or {{(else
    123125EXPRESSION ...)}}.
    124126
    125 The variable {{object}} is bound to the object to coerce within {{CASE ...}}.
    126 
    127 The variable {{on-error}} is bound to a thunk within {{CASE ...}}} to invoke on error.
     127The variable {{object}} is bound to the object to coerce within the scope of
     128{{CASE ...}}.
     129
     130The variable {{on-error}} is bound to a thunk within the scope of {{CASE ...}}}
     131to invoke upon failure.
    128132
    129133<enscript language=scheme>
     
    152156==== coerce-extended?
    153157
    154 <procedure>(coerce-extended? TYPE-SYMBOL)</procedure>
    155 
    156 Is the domain extended to cover the type identifier {{TYPE-SYMBOL}}.
     158<procedure>(coerce-extended? TYPE-TAG) => BOOLEAN</procedure>
     159
     160Is the domain extended to cover the type identifier {{TYPE-TAG}}.
    157161
    158162==== coerce-extend!
    159163
    160 <procedure>(coerce-extend! TYPE-SYMBOL PREDICATE CONVERTOR)</procedure>
     164<procedure>(coerce-extend! TYPE-TAG TYPE-PRED CONVERTOR)</procedure>
    161165
    162166Extends the domain of coerce with the type definition
    163 {{(TYPE-SYMBOL PREDICATE CONVERTOR)}}.
    164 
    165 {{PREDICATE}} is a procedure, {{(object -> boolean)}},
     167{{(TYPE-TAG TYPE-PRED CONVERTOR)}}.
     168
     169{{TYPE-PRED}} is a procedure, {{(object -> boolean)}},
    166170testing whether the argument is a type.
    167171
     
    176180==== coerce-composite-extension!
    177181
    178 <procedure>(coerce-composite-extension! TYPE-SYMBOL PREDICATE CONVERTOR)</procedure>
     182<procedure>(coerce-composite-extension! TYPE-TAG TYPE-PRED CONVERTOR)</procedure>
    179183
    180184Extends the domain of an existing coerce extension.
    181185
    182 {{TYPE-SYMBOL}}, {{PREDICATE}}, and {{CONVERTOR}} are as
     186{{TYPE-TAG}}, {{TYPE-PRED}}, and {{CONVERTOR}} are as
    183187for {{extend-coerce}}.
    184188
     
    186190then the existing procedure is try'ed "on-error".
    187191
    188 Should the new {{PREDICATE}} and existing predicate be {{eq?}} the
    189 predicates are not "composited" using {{or}}.
     192Should the new {{TYPE-PRED}} and existing TYPE-PRED be {{eq?}} the
     193TYPE-PREDs are not "composited" using {{or}}.
    190194
    191195==== coerce-extension-remove!
    192196
    193 <procedure>(coerce-extension-remove! TYPE-SYMBOL)</procedure>
    194 
    195 Delete any existing coerce extension for the type identifier {{TYPE-SYMBOL}}.
     197<procedure>(coerce-extension-remove! TYPE-TAG)</procedure>
     198
     199Delete any existing coerce extension for the type identifier {{TYPE-TAG}}.
    196200
    197201
     
    211215made for {{coerce}}. Please use {{coerce-extend!}} should this be required.
    212216
     217* The coercion of a composite object to a scalar often makes little sense.
     218
     219* The coercion of a scalar object to a composite is usually just to box the
     220object with the specified composite.
     221
    213222* Renames some procedures from the Chicken 3 version.
    214223
     
    222231== Bugs and Limitations
    223232
     233* Cannot know before attempt if coercion possible.
     234
    224235
    225236== Author
     
    230241== Version history
    231242
     243; 1.1.0 : Added {{pointer}} & {{locative}}. Catch-all is {{object}}.
    232244; 1.0.0 : Initial Chicken 4 release.
    233245
     
    254266ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    255267OTHER DEALINGS IN THE SOFTWARE.
     268
     269"coerce.scm" Scheme Implementation of COMMON-LISP COERCE and TYPE-OF.
     270Copyright (C) 1995, 2001 Aubrey Jaffer
     271
     272Permission to copy this software, to modify it, to redistribute it,
     273to distribute modified versions, and to use it for any purpose is
     274granted, subject to the following restrictions and understandings.
     275
     2761.  Any copy made of this software must include this copyright notice
     277in full.
     278
     2792.  I have made no warranty or representation that the operation of
     280this software will be error-free, and I am under no obligation to
     281provide any services, by way of maintenance, update, or otherwise.
     282
     2833.  In conjunction with products arising from the use of this
     284material, there shall be no use of my name in any advertising,
     285promotional, or sales literature without prior written consent in
     286each case.
     287
Note: See TracChangeset for help on using the changeset viewer.