srfi-102

Procedure Arity Inspection

  1. srfi-102
  2. Documentation
    1. SRFI 102 (Draft)
      1. procedure-arity
      2. procedure-arity-includes?
      3. arity-at-least?
      4. arity-at-least-value
    2. Extensions
      1. fixed-arity->arity-at-least
      2. procedure-arity-available?
      3. procedure-fixed-arity?
      4. procedure-minimum-arity
      5. procedure-arity-set!
      6. append-procedure-arity!
  3. Usage
  4. Examples
  5. Notes
  6. Requirements
  7. Bugs and Limitations
  8. Author
  9. Version history
  10. License

Documentation

From the Draft SRFI 102.

This implementation uses the Chicken procedure-information facility.

SRFI 102 (Draft)

procedure-arity

[procedure] (procedure-arity PROCEDURE) => ARITY-OBJECT

Produces an arity-object representing the arity of PROCEDURE. If #f results, no information is available for PROCEDURE.

If this procedure produces an exact-non-negative-integer, K, then PROCEDURE accepts exactly K arguments; applying PROCEDURE to some number of arguments other than K will result in an arity error.

If this procedure produces an arity-at-least-object, A, then PROCEDURE accepts (arity-at-least-value A) or more arguments; applying PROCEDURE to some number of arguments less than (arity-at-least-value A) will result in an arity error.

If this procedure produces a list, then PROCEDURE accepts any of the arities described by the elements of the list; applying PROCEDURE to some number of arguments not described by an element of the list will result in an arity error.

procedure-arity-includes?

[procedure] (procedure-arity-includes? PROCEDURE K) => BOOLEAN

Returns #t if the PROCEDURE can accept K arguments and #f otherwise. If this procedure returns #f, applying PROCEDURE to K arguments will result in an arity error.

arity-at-least?

[procedure] (arity-at-least? OBJECT) => BOOLEAN

Returns #t if OBJECT is an arity-at-least-object and #f otherwise.

arity-at-least-value

[procedure] (arity-at-least-value A) => INTEGER

Returns the exact-non-negative-integer denoting the minimum number of arguments required by the given A.

Extensions

fixed-arity->arity-at-least

[procedure] (fixed-arity->arity-at-least K) => ARITY-AT-LEAST-OBJECT

Returns a scalar arity-at-least-object for the supplied exact-non-negative-integer K.

procedure-arity-available?

[procedure] (procedure-arity-available? PROCEDURE) => BOOLEAN

Returns #t if the PROCEDURE has arity information.

procedure-fixed-arity?

[procedure] (procedure-fixed-arity? PROCEDURE) => BOOLEAN

Returns #t if the PROCEDURE accepts only a fixed number of arguments.

procedure-minimum-arity

[procedure] (procedure-minimum-arity PROCEDURE) => INTEGER

Returns the minimum number of arguments acceptable by the PROCEDURE.

procedure-arity-set!

[procedure] (procedure-arity-set! PROCEDURE [A | K] ...)

PROCEDURE has arity information from one or more A or K.

K
exact-non-negative-integer
A
scalar arity-at-least-object

append-procedure-arity!

[procedure] (append-procedure-arity! PROCEDURE A | K)

PROCEDURE has arity information from an A or K.

K
exact-non-negative-integer
A
scalar arity-at-least-object

Usage

(require-extension srfi-102)

Examples

Notes

Requirements

Bugs and Limitations

Author

Kon Lovett

Version history

1.0.3
Use compiled setup-helper.
1.0.2
1.0.1
1.0.0
Initial Chicken 4 release.

License

From the Draft SRFI 102 Document Copyright (C) David Van Horn 2009. All Rights Reserved.

Copyright (C) 2009 Kon Lovett. 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.