[r6rs-discuss] [Formal] Protocol environment

From: AndrevanTonder <andre>
Date: Mon Nov 13 21:29:18 2006

---
This message is a formal comment which was submitted to formal-comment_at_r6rs.org, following the requirements described at: http://www.r6rs.org/process.html
---
Name        : Andre van Tonder
Email       : andre at het.brown.edu
Type        : defect
Priority    : minor
Component   : Records
Version     : 5.91
Pages       : 70
Dependencies: None
Summary:
--------
The environment for the protocol is not well specified.
Description:
------------
On page 70, the description:
   (protocol <expression>)
    <Expression> is evaluated in the same environment
    as the define-record-type form, ...
does not clarify whether the protocol can refer to the
predicates and accessors of the same record type being defined.
In other words, is the following possible?
   (define-record-type point
     (fields (immutable x)
             (immutable y))
     (protocol (lambda (p)
                 (case-lambda
                   ((x y) (p x y))         ; ordinary constructor
                   ((pt)  (p (point-x pt)  ; copy existing point
                             (point-y pt)))))))
Here the usages of point-x and point-y are supposed to be the ones being
defined in the same define-record-type.
This is a very useful and reasonable thing to do.
Suggestion:
-----------
Let the protocol <expression> be evaluated in the scope of the bindings
of the constructor, predicate, accessors and mutators being defined in the
define-record-type expression.
Received on Mon Nov 13 2006 - 16:31:33 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:00 UTC