Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == dynamic-import [[toc:]] == Documentation A ''dynamic import'' facility for CHICKEN Scheme. ==== Usage <enscript language=scheme> (import dynamic-import) </enscript> '''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 MDs IDs (default DEF))</syntax> <syntax>(dynamic-import MDs IDs [DEF])</syntax> Attempts to import the identifiers {{IDs}} from a module, in the listed {{MDs}} order. Should no module succeed, the default specification {{DEF}} is used to bind the {{IDs}}. The ''extend module identifier syntax'', ex: (srfi 1) & (main sub1 sub1-1), is supported. However, use does need to be as {{((srfi 1) (main sub1 sub1-1))}}, to prevent misunderstanding. ; {{MD}} ; {{(or symbol (list symbol fixnum) (list-of (or symbol number)))}} ; {{ID}} ; {{(symbol)}} ; {{MDs}} ; {{(or MD (list-of MD))}} ; one or many module specifications ; {{IDs}} ; {{(or ID (list-of ID))}} ; one or many identifiers ; {{DEF}} : {{(default * ...)}} ; default is {{(* ...)}} ; {{DEF}} : {{procedure}} ; default is the result of {{(DEF IDs)}} The {{IDs}} are assigned from the default list, w/ an element for each {{ID}}. ==== dynamic-import-warning <parameter>(dynamic-import-warning [WARN]) -> procedure</parameter> : {{WARN}} ; {{(#!rest -> void)}} ; warning procedure; default {{warning}} : {{WARN}} ; {{#t}} ; default : {{WARN}} ; {{#f}} ; {{void}} === Examples <enscript language=scheme> (import dynamic-import) ;see note in documentation above (enable-warnings #f) ; tcp-listen ... from tcp6 else (chicken tcp) else stub ; ; default is procedure and called unlike the example below ; (dynamic-import (tcp6 (chicken tcp)) (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) ; make, named, failure defaults for the imports (lambda (ids) (map (lambda (id) (lambda _ (error id "no dynamic import"))) ids))) ; ; NOTE on import failure: (tcp-read-timeout ...) ; => Error: (tcp-read-timeout) no such import ; ssl-connect* from openssl else stub ; ; default is literal, a procedure but not called as above. ; ; only one import so only one default; one per import. (dynamic-import openssl ssl-connect* (default (lambda _ (values #f #f)))) ; ; NOTE on import failure: (ssl-connect* ...) ; => #f #f </enscript> == Bugs & Limitations * Very '''not''' portable Scheme. * The toplevel is ''polluted'' due to lack of lexical scope. == Notes * Inspired by Feb 12 '22 #chicken irc discussion. == Requirements * Test dependencies only [[test]] [[test-utils]] [[srfi-1]] == Author [[/users/kon-lovett|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|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 [[/egg-svn-checkout|this page]]. == Version history ; 1.0.2 : Do not drop unknown error conditions. ; 1.0.1 : {{srfi-1}} is a test dependency only. ; 1.0.0 : Swap module & import arguments, support extended module-name syntax, remove {{dynamic-importer}} export. ; 0.1.0 : Removed {{tabulated-list-of}}}. Public Domain. ; 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 This code is in the public domain.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 5 by 8?