chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

First stab at supporting R6RS library syntax

Open lassik opened this issue 2 years ago • 10 comments

From the R7RS-large mailing list:

Who will add R6RS support to Chibi? (Another rhetorical question.)

I'm happy to accept patches which improve R6RS operability without significant increases to the core size. syntax-case and identifier-syntax have been added with minor core changes. The library syntax would have to use implicit phasing and probably punt on versioning. There would be some minor differences in semantics, but I believe e.g. most or all of the portable SRFI libraries would work fine. [The cool Racket libraries that I'd like to use wouldn't work because they generally use the Racket language rather than R6RS.]

Compatibility is great news for me.

If it's OK, I volunteer to try adding support for the R6 (library ...) form as an alternative to R7 define-library. The first draft should probably ignore phasing issues and just do a simple translation of library to define-library?

R6 supports library version numbers: you can write (library (name of the library goes here (1 2 3)) ...) where (1 2 3) is the version number, and can be zero or more nonnegative integers. (In R6 the version number can't contain symbols.) Maybe start off by ignoring the version number in Chibi?

lassik avatar Mar 18 '22 09:03 lassik

cc @mnieper

lassik avatar Mar 18 '22 09:03 lassik

My general thought is unless you can condense the definition into about 5 lines, I'd want to support this by allowing to swap out the (meta) language. Long term this was always the plan, along with language-controlled reader overrides, allowing for non-Scheme languages.

ashinn avatar Mar 18 '22 11:03 ashinn

My hope is the new R7RS "Foundations" group can come up with a language which recognizes both define-library and library (Marc has an idea for expanding the former into the latter).

Currently people tend to use .sld for R7 libs and .sls for R6 libs, but it may not be wise to rely on that distinction long-term.

lassik avatar Mar 19 '22 06:03 lassik

My general thought is unless you can condense the definition into about 5 lines, I'd want to support this by allowing to swap out the (meta) language. Long term this was always the plan, along with language-controlled reader overrides, allowing for non-Scheme languages.

I like the idea of being able to select different startup files in place of init-7.scm and meta-7.scm.

mnieper avatar Mar 19 '22 08:03 mnieper

Oh, the 7 stands for R7RS? I always wondered what it meant.

lassik avatar Mar 19 '22 09:03 lassik

This was already supported by the API, I just didn't provide a command-line option for it. Added.

ashinn avatar Mar 20 '22 01:03 ashinn

Would it be possible to use -r <number> for this? That would match at least Gauche and Sagittarius, making life easier for people who use multiple Schemes.

I know Chibi already has -r[<main>] - run a SRFI-22 main but it's unlikely that people want to run a main that's just a number.

lassik avatar Mar 20 '22 05:03 lassik

(For reference, https://github.com/schemedoc/usage)

lassik avatar Mar 20 '22 05:03 lassik

It would be kind of weird... do you think people would use this option frequently enough on those impls that it would help? There are already a lot of more common options that are different.

ashinn avatar Mar 21 '22 23:03 ashinn

I would also advise against such weird irregularity for an option.

mnieper avatar Mar 22 '22 06:03 mnieper