[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
31.1 SRFI 0
- bigloo syntax: cond-expand [clause]
-
The
cond-expand
form tests for the existence of features at macro-expansion time. It either expands into the body of one of its clauses or signals and error during syntactic processing.cond-expand
expands into the body of the first clause whose feature requirement is currently satisfied (theelse
clause, if present, is selected if none of the previous clauses is selected).A feature requirement has an obvious interpretation as a logical formula, where the variables have meaning true is the feature corresponding to the feature identifier, as specified in the SRFI registry, is in effect at the location of the
cond-expand
form, and false otherwise. A feature requirement is satisfied it its formula is true under this interpretation. The formula may make use of identifier,and
,or
andnot
operators.Since Bigloo version 3.1b,
cond-expand
formula may use the newlibrary
operator that checks if a library exists and is available. Its syntax is:(library <libname>)
.Examples:
(write (cond-expand (srfi-0 (* 1 2)) ((or (library fthread) (library pthread)) (- 4 1)) (else (+ 3 4)))) -| 2 (cond-expand (bigloo (define (command-line-arguments) (command-line))) (else (define (command-line-arguments) '())))
The second example assumes that
bigloo
is an alias for the SRFI associated with the specification of Bigloo (i.e. the documentation for that Scheme system).Since Bigloo 3.4b,
cond-expand
formula may use the newconfig
operator that checks the value of a configuration entry. Its syntax is:(config endianeness little-endian)
. This feature relies on thebigloo-config
function. See System programming for additional details.When writing portable code, the case used for the feature identifier should match the one in the SRFI registry. This is to ensure that the feature identifier will be correctly recognized whether or not the Scheme system is case-sensitive. To support case-insensitive Scheme systems, the feature identifiers in the SRFI registry are guaranteed to be unique even when ignoring the case.
In order to distinguish Bigloo versions, the following symbols are recognized in
cond-expand
forms.-
bigloo
-
bigloo<branch-release>
-
bigloo<major-release>
-
bigloo<major-release><minor-release>
When finalizers have been configured, the two following symbols are recognized by
cond-expand
:-
bigloo-finalizer
-
bigloo-weakptr
Bigloo implements differents SRFI for the compiler and the interpreter. Thus, their are two Bigloo SRFI registers. One for the compiler and one for the interpreter. Bigloo compiler SRFI register contains at least the following symbols:
-
srfi-0
-
srfi-1
-
srfi-2
-
srfi-6
-
srfi-8
-
srfi-9
-
srfi-22
-
srfi-28
-
srfi-30
With respect to the currently used Bigloo back-end, one of these symbols is registered:
-
bigloo-c
-
bigloo-jvm
Bigloo compiler implements the following SRFI:
-
bigloo
-
bigloo-compile
-
bigloo<major-release>
-
bigloo<major-release><minor-release>
Then the
-g
flag is used, the Bigloo compiler additionally implements the SRFI:-
bigloo-debug
Bigloo interpreter implements the following SRFI:
-
bigloo
-
bigloo-eval
-
bigloo<major-release>
-
bigloo<major-release><minor-release>
When a library is used, the name of the library is added to the compiler SRFI register. That is:
(module foo (library srfi1)) (print (cond-expand (srfi1 'with-srfi1) (else 'nothing))) -| 'with-srfi1 (print (eval '(cond-expand (srfi1 'with-srfi1) (else 'nothing)))) -| 'with-srfi1
-
- bigloo procedure: register-eval-srfi! srfi-name
This argument srfi-name is a symbol. It registers srfi-name in the Bigloo interpreter SRFI register. This function must only be used when implementing a library. The code of that library must contain one unique call to
register-eval-srfi!
. Let’s suppose, for instance, aformat
library. The implementation for that library must contain an expression like:(register-eval-srfi! 'format)
Calling
(register-eval-srfi! name)
makesname
supported by interpretedcond-expand
forms.Note: There is no
register-compiler-srfi!
because the compiler automatically registers SRFI when the-library
flags are used. However, it exists several ways to tell the compiler that it actually supports some srfis when compiling some modules.- The first way is to insert calls to
register-eval-srfi!
in the.bigloorc
file (see section Compiler description). - The second, is to use
option
(see section Module declaration) module clause, such as:(module example ... (option (register-srfi! 'srfi-foobar))) ...
- The last way is to use the command line option
-srfi
(see section Compiler description).
- The first way is to insert calls to
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 31, 2014 using texi2html 5.0.