* record type not safely stored
@ 2009-02-02 2:05 Judy Hawkins
2009-02-18 16:56 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Judy Hawkins @ 2009-02-02 2:05 UTC (permalink / raw)
To: bug-guile
#|
I wanted to create records that would remain available throughout a
guile session, but they get stepped on in some way I don't know how
to fix.
See the bottom of this file for a complete guile session illustrating
the bug.
|#
(use-modules (ice-9 rdelim))
(define (wl s) (write-line s))
(define r:type (make-record-type "good-rec" '(laugh sleep)))
(define r:type? (record-predicate r:type))
(define r:constr (record-constructor r:type))
(define r:g:laugh (record-accessor r:type (string->symbol "laugh")))
(define r:s:laugh (record-modifier r:type (string->symbol "laugh")))
(define r:g:sleep (record-accessor r:type (string->symbol "sleep")))
(define r:s:sleep (record-modifier r:type (string->symbol "sleep")))
(define (make-r1)
(let* (
(r1 (r:constr "giggle" "dream"))
)
r1 ;;; return it so I can try to keep it around
)
)
(if (not (defined? (string->symbol "Keep-r1")))
(define Keep-r1 #f))
(define (keep-record-around)
(if (not Keep-r1)
(set! Keep-r1 (make-r1))
(wl "Keep-r1 already has the record"))
)
(keep-record-around)
(wl "Good record?")
(wl (r:type? Keep-r1))
(wl Keep-r1)
#|
guile session: load rb.scm twice, see if Keep-r1 has a valid record.
$ guile
guile> (load "rb.scm")
Good record?
#t
#<good-rec laugh: giggle sleep: dream>
guile> (r:g:laugh Keep-r1)
"giggle"
guile> (load "rb.scm")
Keep-r1 already has the record
Good record?
#f
#<good-rec laugh: giggle sleep: dream>
guile> (r:g:laugh Keep-r1)
ERROR: In procedure %record-type-check:
ERROR: Wrong type record (want `"good-rec"'): #<good-rec laugh: giggle sleep: dream>
ABORT: (wrong-type-arg)
guile>
what I expected was for (r:g:laugh Keep-r1) to work fine both times.
Other types such as strings and procedures treated the same way work
as I expected them to.
|#
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: record type not safely stored
2009-02-02 2:05 record type not safely stored Judy Hawkins
@ 2009-02-18 16:56 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2009-02-18 16:56 UTC (permalink / raw)
To: bug-guile; +Cc: Judy Hawkins
Hi,
Judy Hawkins <jlharkins@yahoo.com> writes:
> (define r:type (make-record-type "good-rec" '(laugh sleep)))
[...]
> guile> (load "rb.scm")
> Good record?
> #t
> #<good-rec laugh: giggle sleep: dream>
>
> guile> (r:g:laugh Keep-r1)
> "giggle"
>
> guile> (load "rb.scm")
> Keep-r1 already has the record
> Good record?
> #f
> #<good-rec laugh: giggle sleep: dream>
>
> guile> (r:g:laugh Keep-r1)
>
> ERROR: In procedure %record-type-check:
> ERROR: Wrong type record (want `"good-rec"'): #<good-rec laugh: giggle sleep: dream>
> ABORT: (wrong-type-arg)
> guile>
>
> what I expected was for (r:g:laugh Keep-r1) to work fine both times.
That's because each load yields a `make-record-type', and the record
type created the second type has the same name as the one created the
first time but it's not `eq?' to it, hence the type mismatch.
Thanks,
Ludo'.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-18 16:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-02 2:05 record type not safely stored Judy Hawkins
2009-02-18 16:56 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).