Marc Nieper-Wißkirchen
2016-07-19 13:37:11 UTC
The following example
((eval 'port? (environment '(scheme base)))
(current-input-port))
evaluates to #t because the standard does not list any value types that may
be incompatible between the program's environment and the eval's
environment.
On the other hand,
((eval 'hash-table? (environment '(srfi 125)))
(make-hash-table (make-eq-comparator)))
may not need to return #t when the sample implementation of SRFI 125 is
used. (I could have replaced the sample implementation SRFI 125 with any
other sample implementation that uses record types to generate new disjoint
types.) The reason is that nothing in the report forbids that environment
loads the library (srfi 125) a second time, creating a fresh record type
that is incompatible with the record type of hash tables in the program's
environment.
This makes the types introduced by the SRFIs, which lead, in particular, to
the Red Edition, second-class types when compared with the basic types in
the report.
I see two obviously solutions for R7RS-large here:
1) During evaluation of a program, every library is only loaded at most
once.
2) The sample implementations should use a type of nongenerative record
(which should then be defined for R7RS-large as soon as possible).
The disadvantage of 1) is that it puts huge constraints on implementations.
A compiler will have to put the libraries initially imported by the program
on the same footing as the libraries later referenced by evaluating an
application of the environment procedure. The huge advantage of 1) is that
it won't come with any surprises for a user of the system.
The disadvantage of 2) is that it only partially solves the problem. Some
libraries like SRFI 128 maintain inner state (think of the registered
comparators). A user may (rightfully?) expect that this still works for
evaluated code.
--
Marc
((eval 'port? (environment '(scheme base)))
(current-input-port))
evaluates to #t because the standard does not list any value types that may
be incompatible between the program's environment and the eval's
environment.
On the other hand,
((eval 'hash-table? (environment '(srfi 125)))
(make-hash-table (make-eq-comparator)))
may not need to return #t when the sample implementation of SRFI 125 is
used. (I could have replaced the sample implementation SRFI 125 with any
other sample implementation that uses record types to generate new disjoint
types.) The reason is that nothing in the report forbids that environment
loads the library (srfi 125) a second time, creating a fresh record type
that is incompatible with the record type of hash tables in the program's
environment.
This makes the types introduced by the SRFIs, which lead, in particular, to
the Red Edition, second-class types when compared with the basic types in
the report.
I see two obviously solutions for R7RS-large here:
1) During evaluation of a program, every library is only loaded at most
once.
2) The sample implementations should use a type of nongenerative record
(which should then be defined for R7RS-large as soon as possible).
The disadvantage of 1) is that it puts huge constraints on implementations.
A compiler will have to put the libraries initially imported by the program
on the same footing as the libraries later referenced by evaluating an
application of the environment procedure. The huge advantage of 1) is that
it won't come with any surprises for a user of the system.
The disadvantage of 2) is that it only partially solves the problem. Some
libraries like SRFI 128 maintain inner state (think of the registered
comparators). A user may (rightfully?) expect that this still works for
evaluated code.
--
Marc
--
You received this message because you are subscribed to the Google Groups "scheme-reports-wg2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scheme-reports-wg2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "scheme-reports-wg2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scheme-reports-wg2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.