Re: IF-IMPLEMENTS restricted to top-level?
Marc Feeley 12 Jan 1999 22:55 UTC
> I have a suggestion to restrict IF-IMPLEMENTS to top-level of a <program>
> thus making it illegal to bury it deep inside program text. This will force
> programmers to separate system-dependent code by building their
> own portable abstractions in a form of macros or procedures instead
> of just patching the program to make it work on a new system.
First of all I don't like forcing programmers into a particular style
of expression. Secondly, I can see the need for conditional
expansion within a procedure definition, such as:
(define (add1 x)
(if-implements SRFI-123
(if (fx= x (most-positive-fixnum)) (error "overflow") (fx+ x 1))
(+ x 1)))
or
(define (pp obj port)
(define width
(if-implements SRFI-234
(port-width port)
79))
(pretty-print obj port width))
> I would
> like to be able to see all the system dependencies right away, as
> soon as I open the file; this is why I also prefer longer, easier to
> spot name like %%if-scheme-system-implements.
I'm willing to consider a different name than if-implements. Does
anyone have something better?
> BTW, how am I supposed to write IF-IMPLEMENTS to be able to
> check whether a certain system is case-sensitive? Are both
> if-implements and IF-IMPLEMENTS ok for this purpose?
No, only if-implements (in lowercase) is valid in a case-sensitive
system (so to have portable code you have to write it in lowercase
which will work in case-sensitive and case-insensitive systems). Note
that the specification of SRFI-0 is such that you can test if the
Scheme system is case-sensitive using:
(if-implements srfi-0
...case-insensitive...
...case-sensitive...)
I'm not suggesting that people start using this to test case
sensitivity. This should probably be specified by a separate SRFI
(with details as to whether character names, #t and #f, etc are
case-sensitive).
Marc