dynamic-import

  1. dynamic-import
  2. Documentation
    1. Usage
    2. dynamic-import
    3. dynamic-importer
    4. dynamic-import-warning
    5. tabulated-list-of
    6. Examples
  3. Bugs & Limitations
  4. Notes
  5. Requirements
  6. Author
  7. Repository
  8. Version history
  9. License

Documentation

A dynamic import facility for CHICKEN Scheme.

Usage

(import dynamic-import)

Note strongly suggest warnings be disabled before using dynamic-import: (enable-warnings #f).

"Warning: imported identifier doesn't exist in module ..." can occur due to missing exported identifiers during module search. Also, warnings from dynamic-import flow thru a different channel.

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 ; default : 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)

;see note above
(enable-warnings #f)

;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
(dynamic-import ssl-connect* openssl (default (lambda _ (values #f #f))))

Bugs & Limitations

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.3
Drop warning-on; see error-utils warning-on.
0.0.2
Restrict import list, add warning-on.
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.