This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Ticket 399: clarify which primitives are allowed to implicitly force

2012-10-07 11:30:53
WG1 - Core
2012-06-10 10:59:39

The standard allows the following extension to force:

Some implementations may implement "implicit forcing," where the value of a promise is forced by primitive procedures like `cdr' and `+'

We should remove this note or tighten the definition.

  1. Procedures whose arguments belong to specific types should be allowed to force promises to see if the value of the promise belongs to that type. That covers cdr and + and the great majority of standard procedures.
  2. The type-identifying predicates number? complex? real? rational? integer? boolean? pair? null? list? symbol? char? string? vector? bytevector? procedure? error-object? input-port? output-port? textual-port? binary-port? port? eof-object? should likewise be allowed to force promises, given that promises are not a disjoint type and there is no way to identify one. So number? should be allowed to return #t either on a number or a promise whose value is a number.
  3. The constructors cons list vector, the pseudo-constructor values, and the mutators set-car! set-cdr! list-set! vector-set! should not be allowed to force promises. A promise is an object, and it should be possible to put it into a data structure without forcing it. Likewise, the keyed accessors memq memv member assq assv assoc should be able to retrieve a promise from a list.
  4. I don't have a good intuition about the remaining procedures that accept arbitrary objects. They seem to fall into these groups:
    1. make-promise: what happens if the argument is already a promise? The draft doesn't say.
    2. the equivalence predicates eq? eqv? equal?: should promises be distinct from their values?
    3. not: can a promise whose value is #f count as false?
    4. the error procedures raise raise-continuable error: what's to be done?
    5. the output procedures write write-simple display: what's to be done?
    6. exit: what's to be done?
    7. list-copy: the argument is normally a list, but can be an arbitrary object (a degenerate case of an improper list) in which case it returns the object.

WG1 voted to adopt the rule that a procedure which performs a type-check on its arguments is permitted to implicitly force promises.