(import (rnrs records syntactic) (rnrs base))
(define-record-type(#{I have one field, but no need to set it, I'll do it myself}# make-1 type-1?) (fields (immutable #{field with a fixed value}# #{get first field value}#))
(protocol
(lambda (%make)
(lambda ()
(#;(%make) ;; XXX unlike what is documented, this needs to be:
%make
;; instead. Bug in inmplementation or documentation? Not the issue
;; I wanted to note though.
"some value")))))
(assert (string=? (#{get first field value}# (make-1)) "some value")) ; ok
(define-record-type (#{the subtype}# make-2 type-2?)
(parent #{I have one field, but no need to set it, I'll do it myself}#))
;; The problem:
;;
;; Guile seems to have forgotten that the protocol of the supertype,
;; and hence asks for a value for the argument even though the protocol
;; of the original record type normally would give it a value.
;; (Ok, this is interpretation for the symptoms, I haven't yet tested
this against
;; the source code). ;; ;; This manifests as make-2 havng arity 1 though it should have arity 1: #;(assert (equal? (#{get first field value}# (make-2) "some value"))) ;; --> wrong number of arguments to #<procedure ...>
;; We can due to the bug also break the abstraction: (see assert failure)(assert (equal? (#{get first field value}# (make-2 'break-the-abstraction)) "some value")) ;; --> wrong number of arguments to #<procedure ...>
;; Note: if I explicitly write the protocol for the subtype, then all the problems disappear ;; (work-around). For an example in the wild, see the supertype <lost-and-found> at ;; <https://git.gnunet.org/gnunet-scheme.git/tree/gnu/gnunet/concurrency/lost-and-found.scm> ;; and the subtype at <https://git.gnunet.org/gnunet-scheme.git/tree/gnu/gnunet/dht/client.scm#n583> ;; (Not the best example, as I give the new fields default values as well, but you get the idea.)
OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature
