From: Philip McGrath <philip@philipmcgrath.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: Ricardo Wurmus <rekado@elephly.net>, guix-devel@gnu.org
Subject: Re: better error messages through assertions
Date: Fri, 1 Apr 2022 15:47:18 -0400 [thread overview]
Message-ID: <422d68e3-4ed9-1ea5-88d5-51763a8f4420@philipmcgrath.com> (raw)
In-Reply-To: <87lewrwzll.fsf@gnu.org>
Hi,
On 3/30/22 05:37, Ludovic Courtès wrote:
>
>> What is the preferred mechanism for exceptions?
>
> For Guix code, SRFI-34/35.
>
>> Likewise, what record system should I use?
>
> SRFI-9.
>
> (Perhaps we should put answers to these questions in the “Coding Style”
> section of the manual.)
>
As I've looked more closely, I think I'd be porting a fair amount of
code that looks like this:
```
(define-struct (blame-no-swap blame) ()
#:property prop:equal+hash
(list blame=? blame-hash blame-secondary-hash))
```
That code creates a new opaque struct type `blame-no-swap` with parent
type `blame` and customizes the behavior of `equal?` and `equal?`-based
hashing (but the customization only applies when the two
potentially-equal values are both immediate instances of
`blame-no-swap`, not a supertype or subtype).
It looks like SRFI 9 doesn't have a notion of opaque or parent types, so
it seems like it would be easier to use R6RS records as the basis for
porting.
(I think it should still work to use SRFI 9 records for the interface.
But I know the representation of blame, among other details, has gotten
a lot of attention over the years, so it seems like it would be good to
keep the port as close as reasonably possible to the Racket implementation.)
I'm less sure about `equal?` and hashing. I see in [1] that `equal?` can
be controlled via GOOPS, and I have the impression that there's some
kind of bridging between basic types and GOOPS, but I'm not clear on the
details. I don't see anything explicitly about customizing `hash`[2],
but maybe that would work the same way?
-Philip
[1]:
https://www.gnu.org/software/guile/manual/html_node/GOOPS-Object-Miscellany.html
[2]:
https://www.gnu.org/software/guile/manual/html_node/Hash-Table-Reference.html#index-hash
next prev parent reply other threads:[~2022-04-01 19:47 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 22:32 better error messages through assertions Ricardo Wurmus
2022-02-15 8:48 ` Maxime Devos
2022-02-15 21:45 ` Philip McGrath
2022-02-15 22:15 ` Ricardo Wurmus
2022-02-28 12:59 ` Ludovic Courtès
2022-02-28 16:18 ` Philip McGrath
2022-03-07 10:13 ` Ludovic Courtès
2022-03-28 20:25 ` Philip McGrath
2022-03-30 9:37 ` Ludovic Courtès
2022-03-30 13:28 ` Andy Wingo
2022-04-01 8:47 ` Ludovic Courtès
2022-04-01 19:28 ` Philip McGrath
2022-04-05 12:04 ` Ludovic Courtès
2022-04-01 19:47 ` Philip McGrath [this message]
2022-02-22 4:31 ` Arun Isaac
2022-02-25 18:55 ` Maxim Cournoyer
2022-02-26 13:33 ` Ricardo Wurmus
2022-02-26 13:51 ` Maxim Cournoyer
2022-02-28 13:02 ` Ludovic Courtès
2022-02-28 16:00 ` Maxim Cournoyer
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://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=422d68e3-4ed9-1ea5-88d5-51763a8f4420@philipmcgrath.com \
--to=philip@philipmcgrath.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.org \
--cc=rekado@elephly.net \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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).