You are looking at historical revision 41090 of this page. It may differ significantly from its current revision.

dynamic-import

Documentation

A dynamic import facility for CHICKEN Scheme.

Usage

(import dynamic-import)

dynamic-import

[syntax] (dynamic-import IDs MODs [DEF])

Defines the identifiers IDs, imported from the first available module in MODs, using the default specification DEF when all modules are unproductive.

IDs ; (or symbol (list-of symbol)) ; single, or multiple, identifiers
MODs ; (or symbol (list-of symbol)) ; single, or multiple, module specifications
DEF
(default *) ; use (list * ...) as the default bindings
DEF
list ; use as the default bindings
DEF
((or integer list) --> list) ; use for the default bindings

(length IDs) must match (length DEFs).

dynamic-importer

[procedure] (dynamic-importer IDs MODs [DEF]) -> list

Returns the bindings for the identifiers IDs, from the first available module in MODs, using the default specification DEF when all modules are unproductive.

IDs ; (list-of symbol) ; identifiers
MODs ; (list-of symbol) ; module specifications
DEF
list ; use as the default bindings
DEF
((or integer list) --> list) ; use for the default bindings

(length IDs) must match (length DEFs).

dynamic-import-warning

[parameter] (dynamic-import-warning [WARN]) -> procedure

: WARN ; (#!rest -> void) ; warning procedure, default warning : WARN ; #t ; warning : WARN ; #f ; void

tabulated-list-of

[procedure] (tabulated-list-of OBJ) -> (#!optional (or integer list) -> (or OBJ (list-of OBJ)))

Returns a procedure producing a list of the supplied object OBJ, of length equal to the integer or the (length list).

(define falses (tabulated-list-of #f))
(falses '(1 2)) ;=> (#f #f)
(falses 1)      ;=> (#f)

Examples

(import dynamic-import)

;tcp-listen ... from tcp6 else (chicken tcp)
(dynamic-import
  (tcp-listen tcp-listener-fileno tcp-listener-port
   tcp-accept tcp-accept-ready? tcp-close
   tcp-abandon-port tcp-buffer-size tcp-connect
   tcp-read-timeout tcp-write-timeout)
  (tcp6 (chicken tcp)))

;ssl-connect* from openssl else stub (no warnings since why not)
(dynamic-import-warning #f)
(dynamic-import ssl-connect* openssl (default (lambda _ (values #f #f))))

Bugs & Limitations

#;1> (import scheme dynamic-import)
...
#;2> (dynamic-import cons* srfi-1)

Note: re-importing already imported identifier: assoc

Note: re-importing already imported identifier: member

Notes

Requirements

srfi-1

test

Author

Kon Lovett

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/dynamic-import

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Version history

0.0.1
Initial Release.

License

Copyright (C) 2022 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.