Bug on sample implementation Takashi Kato (04 Jul 2016 09:24 UTC)
Re: Bug on sample implementation Marc Nieper-Wißkirchen (04 Jul 2016 11:18 UTC)

Bug on sample implementation Takashi Kato 04 Jul 2016 09:24 UTC

Hi,

The constructor procedure on the sample implementation doesn't work as its
specified on the SRFI. I've written the following script:

(import (except (scheme base) define-record-type) (srfi 136)
    (scheme write))

(define-record-type foo (make-foo a b) foo?
  (a foo-a)
  (b foo-b))
(define-record-type (bar foo) make-bar bar?
  (c bar-a)
  (d bar-b))

(define (check r p? a1 a2)
  (display r) (newline)
  (display (p? r)) (newline)
  (display (a1 r)) (newline)
  (display (a2 r)) (newline)
  (newline))

(check (make-foo 1 2 3 4) foo? foo-a foo-b)
(check (make-bar 1 2 3 4) foo? foo-a foo-b)
(check (make-bar 1 2 3 4) bar? bar-a bar-b)

And got the following output (executed on Sagittarius Scheme 0.7.5):

#<<record> 0x10263a3c0>
#t
1
2

#<<record> 0x102650840>
#t
1
2

#<<record> 0x10268ccc0>
#t
#<unspecified>
#<unspecified>

The first make-foo is an error so it's ok if it works or not (raise an
error would be preferable, though). However the last make-bar and its
accessor, I thought, should print 3 and 4. It didn't work if I make
make-bar definition to (make-bar c d), either.

Cheers,

--
_/_/
Takashi Kato
E-mail: ktakashi19@gmail.com