Why not a data type promise in a schema?

The object returned by delay in the Schema is a "promise", but promises are not considered a type (therefore, there is no promise? Procedure and it is not specified as a type in R5RS or R6RS).

Is there a strong reason why this is so? It would be completely natural for me to do something like (if (promise? x) (force x) x) , for example. (And I see that some implementations will allow me not to force promises, while others will not). Also, if I can store something in variale and pass it on, I feel like it should be of type.

+6
lazy-evaluation scheme
source share
2 answers

There can be no such strong reason, since the MIT / GNU scheme defines the promise? function promise? .

+4
source share

I think this allows a more optimized implementation of delay/force . The fact that a coercive value can be seen (so that a promise is really coercive only once, and the received value is returned on subsequent calls to force ), blurs the distinction between the promise and its final value. If you have a promise? , you cannot replace a forced promise by its value wherever it is needed. Therefore, depending on the implementation, the promise may be indistinguishable from any other meaning of the Scheme.

+4
source share

All Articles