source: project/wiki/eggref/4/srfi-102 @ 28453

Last change on this file since 28453 was 28453, checked in by Kon Lovett, 8 years ago

rel 1.0.3 & 1.0.2

File size: 5.2 KB
Line 
1[[tags: egg]]
2
3== srfi-102
4
5Procedure Arity Inspection
6
7[[toc:]]
8
9
10== Documentation
11
12From the Draft [[http://srfi.schemers.org/srfi-102/srfi-102.html|SRFI 102]].
13
14This implementation uses the Chicken {{procedure-information}} facility.
15
16=== SRFI 102 (''Draft'')
17
18==== procedure-arity
19
20<procedure>(procedure-arity PROCEDURE) => ARITY-OBJECT</procedure>
21
22Produces an {{arity-object}} representing the arity of {{PROCEDURE}}. If {{#f}}
23results, no information is available for {{PROCEDURE}}.
24
25If this procedure produces an {{exact-non-negative-integer}}, {{K}}, then
26{{PROCEDURE}} accepts exactly {{K}} arguments; applying {{PROCEDURE}} to some
27number of arguments other than {{K}} will result in an arity error.
28
29If this procedure produces an {{arity-at-least-object}}, {{A}}, then
30{{PROCEDURE}} accepts {{(arity-at-least-value A)}} or more arguments; applying
31{{PROCEDURE}} to some number of arguments less than {{(arity-at-least-value
32A)}} will result in an arity error.
33
34If this procedure produces a {{list}}, then {{PROCEDURE}} accepts any of the
35arities described by the elements of the list; applying {{PROCEDURE}} to some
36number of arguments not described by an element of the list will result in an
37arity error.
38
39==== procedure-arity-includes?
40
41<procedure>(procedure-arity-includes? PROCEDURE K) => BOOLEAN</procedure>
42
43Returns {{#t}} if the {{PROCEDURE}} can accept {{K}} arguments and {{#f}}
44otherwise. If this procedure returns {{#f}}, applying {{PROCEDURE}} to {{K}}
45arguments will result in an arity error.
46
47==== arity-at-least?
48
49<procedure>(arity-at-least? OBJECT) => BOOLEAN</procedure>
50
51Returns {{#t}} if {{OBJECT}} is an {{arity-at-least-object}} and {{#f}}
52otherwise.
53
54==== arity-at-least-value
55
56<procedure>(arity-at-least-value A) => INTEGER</procedure>
57
58Returns the {{exact-non-negative-integer}} denoting the minimum number of
59arguments required by the given {{A}}.
60
61=== Extensions
62
63==== fixed-arity->arity-at-least
64
65<procedure>(fixed-arity->arity-at-least K) => ARITY-AT-LEAST-OBJECT</procedure>
66
67Returns a scalar {{arity-at-least-object}} for the supplied
68{{exact-non-negative-integer}} {{K}}.
69
70==== procedure-arity-available?
71
72<procedure>(procedure-arity-available? PROCEDURE) => BOOLEAN</procedure>
73
74Returns {{#t}} if the {{PROCEDURE}} has arity information.
75
76==== procedure-fixed-arity?
77
78<procedure>(procedure-fixed-arity? PROCEDURE) => BOOLEAN</procedure>
79
80Returns {{#t}} if the {{PROCEDURE}} accepts only a fixed number of arguments.
81
82==== procedure-minimum-arity
83
84<procedure>(procedure-minimum-arity PROCEDURE) => INTEGER</procedure>
85
86Returns the minimum number of arguments acceptable by the {{PROCEDURE}}.
87
88==== procedure-arity-set!
89
90<procedure>(procedure-arity-set! PROCEDURE [A | K] ...)</procedure>
91
92{{PROCEDURE}} has arity information from one or more {{A}} or {{K}}.
93
94; {{K}} : {{exact-non-negative-integer}}
95
96; {{A}} : scalar {{arity-at-least-object}}
97
98==== append-procedure-arity!
99
100<procedure>(append-procedure-arity! PROCEDURE A | K)</procedure>
101
102{{PROCEDURE}} has arity information from an {{A}} or {{K}}.
103
104; {{K}} : {{exact-non-negative-integer}}
105
106; {{A}} : scalar {{arity-at-least-object}}
107
108
109== Usage
110
111<enscript language=scheme>
112(require-extension srfi-102)
113</enscript>
114
115
116== Examples
117
118* See the "run.scm" test source.
119
120
121== Notes
122
123* To call this a ''work in progress'' is an understatement. The pulling of
124procedure arity & name from the {{lambda-info}} type is a hack.
125
126* The module {{procedure-introspection}} provides the routines for this
127extension.
128
129* The draft SRFI 102 routines are built from the primitives suggested by Arthur
130A. Gleckler.
131
132* The author is not a fan of this SRFI (draft!) but it is an interesting
133exercise.
134
135
136== Requirements
137
138
139== Bugs and Limitations
140
141* When no {{lambda-info}} is available no arity info is available.
142
143* When a source is compiled with '-no-lambda-info' no arity info is available.
144
145* Anonymous, Composed & Curried procedures must have an explicitly set arity.
146
147* Support for {{case-lambda}} and {{match-lambda}} is not automatic.
148
149
150== Author
151
152[[/users/kon-lovett|Kon Lovett]]
153
154
155== Version history
156
157; 1.0.3 : Use compiled setup-helper.
158; 1.0.2 :
159; 1.0.1 :
160; 1.0.0 : Initial Chicken 4 release.
161
162
163== License
164
165From the Draft SRFI 102 Document Copyright (C) David Van Horn 2009. All Rights
166Reserved.
167
168Copyright (C) 2009 Kon Lovett.  All rights reserved.
169
170Permission is hereby granted, free of charge, to any person obtaining a copy of
171this software and associated documentation files (the Software), to deal in the
172Software without restriction, including without limitation the rights to use,
173copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
174Software, and to permit persons to whom the Software is furnished to do so,
175subject to the following conditions:
176
177The above copyright notice and this permission notice shall be included in all
178copies or substantial portions of the Software.
179
180THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
181IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
182FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
183AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
184LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
185OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
186SOFTWARE.
Note: See TracBrowser for help on using the repository browser.