Agree. Note though that SRFIs are not mean for changes to Scheme
itself (even though they may be considered for future versions). They
exist as a reference for Scheme implementors (that in the case of
Scheme, are too many). Lets say you come up with an API for using
sockets, you like it and think it is very Shen-like and other ports
could implement it, so you share it with others so that we can discuss
it and agree on a common API. Each port can then expose this API to
users (even if they also provide a different API), but it is up to
each port, and Shen itself does not change.
What is important here is that except for some particular cases, it is
not even necessary for the port maintainer to have to take care of
implementing the SRFI, a third party can do it (at least, as long as
the port provides access to the underlying platform). If I don't feel
like implementing the sockets API because I'm not interested in
network programming or don't have time to do so, someone else who is
interested can do it and provide it as a library.
It is also common for SRFIs to (in addition of defining and
documenting the expected API) provide a portable implementation that
will not require any port to change anything for the functionality to
be available. But Scheme implementations are free (and in some cases
encouraged) to implement the API natively (for performance or other
reasons) as long as they conform to the defined API (SRFI-4[1] and
SRFI-[9] are two good examples of SRFIs with portable implementations
that are very commonly implemented natively).
For almost everything that has been discussed here, it is just up to
us to decide on a common interface and provide it without needing to
change the Shen spec.
So:
- Error output stream: could be named *erroutput*, easy (1 line) in
chibi-shen and I'm sure it is easy in other ports
- Access to command-line arguments: could be done like shen_run
(function named main that receives a list), easy in chibi-shen too,
and probably easy in other ports too (and for ports that don't
implement it natively, there is shen_run). Could also be a variable as
you suggest. Haven't thought about it much but I don't have any strong
preference for now.
- Suppressing output, ports could set *hush* to true when running in
"standalone program" mode
- Standard way to exist: providing (exit N) sounds good to me, and I
don't think it is a hard thing to do in any port.
The one that I think would ideally be done as an internal change in
Shen but can still be changed from the outside:
- Partial function handling: if running in "standalone program" mode,
you could forcibly overwrite `shen.f_error`[3] so that it raises an
error, but here you are depending on Shen's internals that may change
in the future. Alternatively, when compiling your programs have
`shen.err-condition`[4] return code to trigger an error as the last
condition instead of a call to `shen.f_error`.
Then there is `compile` working with arbitrary streams (I would also
like that btw, but then also maybe a different library should be
written), but that requires a direct change to Shen-YACC, because the
code it generates uses `hd` / `tl` /`cons?`. This generated Kl code
could be post-processed to change those calls, but sounds too
complicated and fragile to me, so, not really a solution.
[1]
http://srfi.schemers.org/srfi-4/srfi-4.html
[2]
http://srfi.schemers.org/srfi-9/srfi-9.html
[3]
https://github.com/Shen-Language/shen-sources/blob/shen-18.1/sources/track.shen#L33-L39
[4]
https://github.com/Shen-Language/shen-sources/blob/shen-18.1/sources/core.shen#L388-L389
> Greg