Re: Conditional include

2021-07-18 Thread John Cowan
On Sun, Jul 18, 2021 at 10:16 AM Lassi Kortela  wrote:


> R6RS implementations have a convention of appending the implementation's
> name to the filename.
> Best of all is the R7RS solution:
>

Oh, absolutely.  I didn't choose those four for no reason.  I wanted a pure
R7 system, an R5+ system that supports cond-expand, a hybrid R5-R6 system,
and a pure R6 system.  With those, it was easy to see how to extend it to
any system, pretty much.  (The worst case is R5RS without cond-expand: in
that case, you don't worry about the library and just load the
implementation, possibly with a shim file.)


Conditional include

2021-07-18 Thread Lassi Kortela
Lassi: The fact that different Schemes have different conventions for 
where their library files are is actually a great convenience to me when 
developing SRFIs.  All the actual code goes into files named *-impl.scm 
(or multiple names if there are multiple files).  Then each library file 
or equivalent, which is where the differences are concentrated, is in an 
implementation-specific place.  The library file for (foo bar) will be at:


Chibi:  foo/bar.sld
Chicken: foo.bar.scm
Guile: foo/bar.scm
Ypsilon: foo/bar.sls, or foo/bar.ypsilon.sls if it is Ypsilon-specific

And since each of these needs to be slightly different, that's a Good Thing.


This is suboptimal: the meaning is obscured, and things work by accident 
since you have only 4 Schemes and all of them happen to use different 
naming conventions. If you add more Schemes, some of them will 
eventually clash.


R6RS implementations have a convention of appending the implementation's 
name to the filename. For example, 
 has the files:


parameters.sls  ; Portable version of the code.
parameters.chezscheme.sls
parameters.ikarus.sls
parameters.ironscheme.sls
parameters.mzscheme.sls
parameters.ypsilon.sls

This is clearer and more likely to avoid clashes.

Best of all is the R7RS solution:

(define-library (foo)
  (cond-expand (chicken (include "foo.chicken.scm"