Changeset 9010 in project


Ignore:
Timestamp:
02/26/08 01:10:56 (12 years ago)
Author:
Kon Lovett
Message:

Added tags.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/coerce

    r8974 r9010  
    1111=== Author
    1212
    13 [[Kon Lovett]]
     13Ported to Chicken: [[Kon Lovett]]
    1414
    1515=== Requirements
     
    2727extensions, which implements object type conversion.
    2828
    29 <procedure>(type-of object)</procedure>
     29==== type-of
    3030
    31 Returns a symbol name for the type of {{object}}.
     31<procedure>(type-of OBJECT)</procedure>
    3232
    33 <procedure>(coerce object result-type [default-proc])</procedure>
     33Returns a symbolic name for the type of {{OBJECT}}.
    3434
    35 Converts and returns {{object}} to {{result-type}}.
     35==== coerce
    3636
    37 {{result-type}} is a symbol.
     37<procedure>(coerce OBJECT RESULT-TYPE [DEFAULT])</procedure>
    3838
    39 {{default-proc}} is {{(-> object-type-symbol object result-type-symbol
    40 object)}} and is invoked when coercion fails.
     39Converts {{OBJECT}} to a {{RESULT-TYPE}} value.
    4140
    42 Builtin types are {{char}}, {{number}},
    43 {{string}}, {{symbol}}, {{list}}, and {{vector}}.
     41{{RESULT-TYPE}} is a symbol.
    4442
     43{{DEFAULT}} is {{(object-type-symbol object result-type-symbol -> object)}} and
     44is invoked when coercion fails.
    4545
    46 <procedure>(coerce-all list-of-object list-of-result-type [default-proc])</procedure>
     46Built-in types are {{char}}, {{number}}, {{string}}, {{symbol}}, {{list}}, and {{vector}}.
    4747
    48 Returns a list of every element of {{list-of-object}} coerced to the corresponding
    49 element of {{list-of-result-type}}.
     48==== coerce-all
    5049
    51 {{default-proc}} and {{result-type}} are as for {{coerce}}.
     50<procedure>(coerce-all LIST-OF-OBJECT LIST-OF-RESULT-TYPE [DEFAULT])</procedure>
    5251
    53 <procedure>(extend-coerce identifier predicate convertor)</procedure>
     52Returns a list of every element of {{LIST-OF-OBJECT}} coerced to the corresponding
     53element of {{LIST-OF-RESULT-TYPE}}.
     54
     55{{DEFAULT}} and {{RESULT-TYPE}} are as for {{coerce}}.
     56
     57==== extend-coerce
     58
     59<procedure>(extend-coerce IDENTIFIER PREDICATE CONVERTOR)</procedure>
    5460
    5561Extends the domain of coerce with the type definition
    56 {{{identifier predicate convertor}}}.
     62{{{IDENTIFIER PREDICATE CONVERTOR}}}.
    5763
    58 {{identifier}} is a symbol.
     64{{IDENTIFIER}} is a symbol.
    5965
    60 {{predicate}} is a procedure, {{(-> object boolean)}},
     66{{PREDICATE}} is a procedure, {{(object -> boolean)}},
    6167testing whether the argument is a type.
    6268
    63 {{convertor}} is a procedure, {{(-> object symbol
    64 on-error object)}}, converting from the type to a result type.
     69{{CONVERTOR}} is a procedure, {{(object symbol on-error -> object)}},
     70converting from the type to a result type.
    6571
    66 The {{convertor}} '''must''' invoke {{(on-error)}} when conversion not
     72The {{CONVERTOR}} '''must''' invoke {{(on-error)}} when conversion not
    6773possible. Usually {{case-coerce}} would be used to create the
    68 {{convertor}}, which automatically handles calling of the {{on-error}}
    69 parameter.
     74{{CONVERTOR}}, which automatically handles calling of the {{on-error}}
     75argument.
    7076
    71 <procedure>(composite-coerce-extension identifier predicate convertor)</procedure>
     77==== composite-coerce-extension
     78
     79<procedure>(composite-coerce-extension IDENTIFIER PREDICATE CONVERTOR)</procedure>
    7280
    7381Extends the domain of an existing coerce extension.
    7482
    75 {{identifier}}, {{predicate}}, and {{convertor}} are as
     83{{IDENTIFIER}}, {{PREDICATE}}, and {{CONVERTOR}} are as
    7684for {{extend-coerce}}.
    7785
    78 The new {{convertor}} is try'ed before the existing procedure,
     86The new {{CONVERTOR}} is try'ed before the existing procedure,
    7987then the existing procedure is try'ed "on-error".
    8088
    81 Should the new {{predicate}} and existing predicate be {{eq?}} the
     89Should the new {{PREDICATE}} and existing predicate be {{eq?}} the
    8290predicates are not "composited" using {{or}}.
    8391
    84 <procedure>(remove-coerce-extension identifier)</procedure>
     92==== remove-coerce-extension
    8593
    86 Delete any existing coerce extension for {{identifier}}.
     94<procedure>(remove-coerce-extension IDENTIFIER)</procedure>
    8795
    88 <procedure>(make-case-coerce convertor [alist])</procedure>
     96Delete any existing coerce extension for {{IDENTIFIER}}.
     97
     98==== make-case-coerce
     99
     100<procedure>(make-case-coerce CONVERTOR [ALIST])</procedure>
    89101
    90102Returns a coercion procedure for use with {{extend-coerce}}
    91103
    92 {{convertor}} is a coercion procedure, {{(-> object symbol on-error
    93 object)}}.
     104{{CONVERTOR}} is a coercion procedure, {{(object symbol on-error -> object)}}.
    94105
    95 {{alist}} is a list of {{(symbol . (-> object object))}}.
     106{{ALIST}} is a list of {{(symbol . (object -> object)}}.
    96107
    97 <macro>(case-coerce case ...)</macro>
     108==== case-coerce
     109
     110<macro>(case-coerce CASE ...)</macro>
    98111
    99112Returns a coercion procedure for use with {{extend-coerce}}.
    100113
    101 {{case}} is of the form {{((symbol ...) expression ...)}}, or {{(else expression ...)}}
     114{{CASE}} is of the form {{((SYMBOL ...) EXPRESSION ...)}}, or {{(else
     115EXPRESSION ...)}}
    102116
    103 The variable {{object}} is bound to the object to coerce within the case-body, {{case ...}}.
     117The variable {{OBJECT}} is bound to the object to coerce within the case-body,
     118{{CASE ...}}.
    104119
    105 The variable {{on-error}} is bound to a thunk within the case-body,
    106 {{case ...}}, to invoke on error.
     120The variable {{on-error}} is bound to a thunk within the case-body, {{CASE
     121...}}, to invoke on error.
    107122
    108123=== Changelog
     
    119134  Copyright (c) 2006, Kon Lovett
    120135  All rights reserved.
    121  
     136
    122137  Redistribution and use in source and binary forms, with or without
    123138  modification, are permitted provided that the following conditions are
    124139  met:
    125  
     140
    126141  Redistributions of source code must retain the above copyright
    127142  notice, this list of conditions and the following disclaimer.
    128  
     143
    129144  Redistributions in binary form must reproduce the above copyright
    130145  notice, this list of conditions and the following disclaimer in the
    131146  documentation and/or other materials provided with the distribution.
    132  
     147
    133148  Neither the name of the author nor the names of its contributors may
    134149  be used to endorse or promote products derived from this software
    135150  without specific prior written permission.
    136  
     151
    137152  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    138153  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Note: See TracChangeset for help on using the changeset viewer.