From: Jonathan S. Shapiro <shap@er...> - 2008-01-21 22:58:42
At the time I last worked on it, TinyScheme didn't do string streams.
Implementing is a moderate pain in the ass, but only moderate. There is
one very unfortunate problem, however:
1. At bottom, the out of memory handler down in GC attempts
to issue a diagnostic to the current error stream.
2. Issuing a string to a string stream requires memory allocation.
3. Because of this, there is a problem if the current error stream
is allowed to be a string stream.
4. The standard (implicitly) requires that this be allowed.
I happened to be poking at the R6RS site, and it appears that the latest
Scheme introduces some form of exception handling. The standard seems to
introduce exceptions as a library, but I do not see any reason why this
could not be implemented as a new, primitive object type in the runtime.
Switching the current behavior to raise a (statically preallocated)
exception would resolve many problems.
If this approach is adopted, I would reluctantly but strongly recommend
removing call/cc and dynamic-wind. Both constructs are very important to
Scheme idioms, but they are completely incompatible with a successful
scripting language. Illustration:
1. Scheme code runs, calls
2. C code, which in turn calls
3. Scheme code, which captures a continuation via CALL/CC into
some global variable.
$5 to anybody who can explain what happens to the C stack in the middle
when this continuation is called.
A less draconian solution is to say that the lifetime of a continuation
in TinyScheme is bounded by the lifetime of its call/cc form, and that
continuations are destroyed by invocation. Subsequent invocations of
call/cc raise an exception. This effectively guarantees that
continuations can never be invoked in the dangerous downward form. At
one point, some analysis was done on existing Scheme usage, and it was
found that the overwhelming majority of Scheme programs will work just
fine within this restriction.
Get latest updates about Open Source Projects, Conferences and News.