Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial R6RS library compatibility #1003

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

Partial R6RS library compatibility #1003

wants to merge 7 commits into from

Conversation

dpk
Copy link
Contributor

@dpk dpk commented Oct 6, 2024

Aiming for Guile/Larceny-style R6RS compatibility, rather than Chez-style R6RS total conformance. A correct R6RS library will work, but error cases will reflect Chibi’s existing style rather than what R6RS strictly demands.

Still to do:

  • I’m not sure clean-up-r6rs-import handles all cases yet
  • Support .sls extension for library files, looking for .chibi.sls first
  • Decide what to do about SRFI 97-style library names (add redundant libraries for all of them, as in Arcfide’s chez-srfi project?)
  • Decide what to do about square brackets
  • Add the remaining (rnrs ...) libraries, probably piggybacking off the R6RS-cleanup SRFIs like 181 and 237/240 where appropriate
    • Decide how to support R6RS conditions within Chibi’s R7RS error object style system
  • Modify the expander to use the R6RS order at least for procedure and library bodies (which is R7RS-compatible; there is a deeper issue with program bodies, see In R7RS programs, right hand sides of definitions are expanded too late larcenists/larceny#825)

If there is interest I will do these things. The only ‘core’ change is the one already made in meta-7.scm; for total support it also needs the macro expander body processing order change, which I don’t expect to be a massive change either. For square brackets it depends on the overall approach taken (#883).

Copy link
Owner

@ashinn ashinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! In general I'm OK with a change of this size for now, but the key question is how to handle the file extensions. It was always the intention to support other languages (notably javascript), and load a different parser & evaluator based on the file extension, and that should be handled dynamically.

But if we can do so with minimal core changes I'm OK with more native R6RS support.

lib/meta-7.scm Outdated Show resolved Hide resolved
lib/meta-7.scm Outdated Show resolved Hide resolved
lib/rnrs/base.sld Show resolved Hide resolved
@dpk dpk mentioned this pull request Oct 26, 2024
@dpk
Copy link
Contributor Author

dpk commented Nov 2, 2024

Replying to something you said in #1010 over here, because it’s more relevant to this issue.

To my knowledge, #1010 (or some equivalent change supporting the same feature) is the only change that will need to be made to init-7.scm to support an R6RS feature. It does not change anything for existing Chibi/R7RS programs.

Disclaimer: Of course, I don’t know for certain until I actually try to implement these things.

The other ‘core’ changes, as noted above, are: square bracket support in the reader (#883); supporting .sls as a file extension for libraries (even this is not strictly necessary since R6RS doesn’t say anything about file names, but .sls is the convention in the same way .sld is on R7RS); and changing the expander to expand all syntax definitions before expanding all other definitions and expressions in procedures and libraries.

Perhaps we should talk more about those changes before I make too much further progress.

@dpk dpk force-pushed the r6rs branch 2 times, most recently from 9df9beb to 5053f25 Compare November 2, 2024 11:12
@ashinn
Copy link
Owner

ashinn commented Nov 2, 2024

The other ‘core’ changes, as noted above, are: square bracket support in the reader (#883);

Support for customizing square brackets is fine. Note it's likely the default behavior will become square brackets as array literals for compatibility with Remora.

supporting .sls as a file extension for libraries (even this is not strictly necessary since R6RS doesn’t say anything about file names, but .sls is the convention in the same way .sld is on R7RS)

Probably not an issue but there's the question of what to do when both .sld and .sls are found, and the general concern about the slowdown when searching for more files.

and changing the expander to expand all syntax definitions before expanding all other definitions and expressions in procedures and libraries.

This may be a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants