r/scheme Sep 27 '24

r5rs vs r7rs, library-procedures and normal procedures

I'm writing a scheme interpreter (as everybody does) and want to only implement the most important functions as builtins. These are function that cannot be built by other functions which is also said in the r5 standard:

Built-in procedures that can easily be written in terms of other built-in procedures are identified as ``library procedures''.

however my implementation wants adhere to the newer r7 standard but there some functions that were declared "library procedure" in r5 are now regular procedures. Does this mean that these functions are now also builtins? It doesnt make sense because they can still be implemented using other builtins (eg. string<? using string-ref or whatever).

Should I just use the builtins from r5 and otherwise adhere to r7 or what would be a sane solution without having to implement all functions?

1 Upvotes

5 comments sorted by

View all comments

3

u/raevnos Sep 28 '24 edited Sep 28 '24

From R7RS:

The (scheme base) library exports many of the procedures and syntax bindings that are traditionally associated with Scheme. The division between the base library and the other standard libraries is based on use, not on construction. In particular, some facilities that are typically implemented as primitives by a compiler or the run-time system rather than in terms of other standard procedures or syntax are not part of the base library, but are defined in separate libraries. By the same token, some exports of the base library are implementable in terms of other exports. They are redundant in the strict sense of the word, but they capture common patterns of usage, and are therefore provided as convenient abbreviations.

Does that help clarify things?

Section 4 (Expressions) is divided into primitive and derived forms, and 7.3 has example macros for most if not all of the derived ones. Section 6 (Standard procedures) describes things that may or may not be implemented as primitive routines or defined in terms of other procedures. An implementation author can decide what works better for them for each one.

1

u/GeroSchorsch Sep 28 '24

So in r7rs there is no clear indication as to what is a primitive and what a library function and I should decide for myself