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

Reply via email to