From: Christopher Lam <christopher.lck@gmail.com>
To: guile-user <guile-user@gnu.org>
Subject: srfi-9 vs make-record-type
Date: Sun, 21 Jul 2019 10:20:29 +0000 [thread overview]
Message-ID: <CAKVAZZKUKEJZtQiEZemDSN17S1_D0U_pe_=DdeiL4C9Ve8vpSg@mail.gmail.com> (raw)
Hi All
In experiments converting legacy code to use srfi-9 records, I'm finding
the latter doesn't travel well across modules.
See simple code below -- m1.scm runs fine however m2.scm borks when
creating srfi-9 record object
Any clue why srfi-9 can't be exported?
For various reasons I must keep (load "module.scm") mechanism
----m1.scm follows----
(use-modules (srfi srfi-9))
(define-record-type <person>
(make-person name age)
person?
(name person-name set-person-name!)
(age person-age set-person-age!))
(define <pet> (make-record-type "pet" '(name age)))
(define make-pet (record-constructor <pet>))
(define pet? (record-predicate <pet>))
(define pet-name (record-accessor <pet> 'name))
(define pet-age (record-accessor <pet> 'age))
(define set-pet-name! (record-modifier <pet> 'name))
(define set-pet-age! (record-modifier <pet> 'age))
(export make-person)
(export make-pet)
(display "pet ")
(let ((pet2 (make-pet "milou" 7)))
(display (pet-name pet2)))
(display ", person ")
(let ((person2 (make-person "james" 54)))
(display (person-name person2)))
(newline)
----m2.scm follows----
(load "m1.scm")
(display "in m2:")
(newline)
(display "pet ")
(let ((pet2 (make-pet "milou" 7)))
(display (pet-name pet2)))
(display ", person ")
(let ((person2 (make-person "james" 54)))
(display (person-name person2)))
(newline)
--------------------------------
$guile m1.scm runs successfully
pet milou, person james
$guile m2.scm first runs m1.scm but fails to recognise the srfi-9
make-person exists:
pet milou, person james
in m2:
pet milou, person Backtrace:
6 (apply-smob/1 #<catch-closure 5599248723e0>)
In ice-9/boot-9.scm:
705:2 5 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
619:8 4 (_ #(#(#<directory (guile-user) 559924904140>)))
In ice-9/boot-9.scm:
2312:4 3 (save-module-excursion _)
3831:12 2 (_)
In /home/chris/sources/caca/m2.scm:
8:15 1 (_)
In unknown file:
0 (_ "james" 54)
ERROR: Wrong type to apply: #<syntax-transformer make-person>
next reply other threads:[~2019-07-21 10:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-21 10:20 Christopher Lam [this message]
2019-07-21 19:21 ` srfi-9 vs make-record-type John Cowan
2019-08-05 18:18 ` Mark H Weaver
2019-08-26 12:20 ` Christopher Lam
2020-07-13 13:07 ` Christopher Lam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKVAZZKUKEJZtQiEZemDSN17S1_D0U_pe_=DdeiL4C9Ve8vpSg@mail.gmail.com' \
--to=christopher.lck@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).