| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
srfi-0 - Feature conditional Provides SRFI-0 cond-expand macro form.
Now this module is autoloaded when cond-expand is used,
so you don't need to say (use srfi-0) explicitly.
Portable programs can't use 'use' form anyway.
[SRFI-0] This macro expands to command-or-definition … if Gauche supports feature-requirement. In a way, it can be used to absorb the different feature sets supported by different Scheme implementations.
feature-requirement must be in the following syntax:
feature-requirement : feature-identifier | (and feature-requirement …) | (or feature-requirement …) | (not feature-requirement) |
feature-identifier is a symbol that indicates a feature. If such a feature is supported in Gauche, it satisfies the feature-requirement. You can do boolean combination of feature-requirements to compose more complex conditions.
The macro tests each feature-requirement in order, and if one is satisfied, the macro itself expands to the corresponding command-or-definition ….
The last clause may begin with a symbol else instead of
feature-requirement. If no condition is fulfilled before
it, then the macro expands to the command-or-definitions
of the else clause. If there's no else clause and no condition
is fulfilled, an error is signalled.
Currently, Gauche recognizes srfi names (e.g. srfi-1)
that it supports (See section Standard conformance, for the list of
supported SRFIs), and a symbol gauche as feature-identifier.
Suppose you are writing a program that requires srfi-13 (string library). In Gauche, the standard way to use srfi-13 is like this:
(use srfi-13) ;; ... your program ... |
However, the 'use' macro is Gauche specific and won't work on other Scheme implementations. You can write instead:
(cond-expand
(srfi-13
;; ... your program ...
))
|
If the implementation supports srfi-13, the form expands
to your program. Note that Gauche issues (use srfi-13)
for you in this case.
The above form signals an error if the implementation doesn't support srfi-13. However, you might want to run your program on such implementations as well, by providing alternative library definitions.
(cond-expand (srfi-13 ;; ... your program ... ) (else (load "my-srfi-13-implementation") ;; ... your program ... )) |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Shiro Kawai on October, 7 2008 using texi2html 1.78.