• Initial comments on SRFI 287 Wolfgang Corcoran-Mathe (22 Oct 2026 23:26 UTC)
    • Re: Initial comments on SRFI 287 D Guthrie (15 Nov 2026 17:27 UTC)

Re: Initial comments on SRFI 287 D Guthrie 15 Nov 2026 17:27 UTC

Hi Wolfgang,

> On 23 Oct 2026, at 00:25, Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz> wrote:
>
> Duncan,
>
> Thanks for coming up with this SRFI and for providing so many examples.
> A few comments, from my initial reading, follow.  I make the usual
> apologies for pedantry.
>
> * Missing word: “R6RS conditions may not be available, in which
> [case] implementations may simply signal an error …”.
>
> I would also allow analogous conditions to be raised in non-R6RS
> condition systems, instead of falling all the way back to ‘error’.
>
>
> * Agreement: “With nlab-comp or elab-comp respectively if they are not
> a SRFI 128 comparator.”  Read “if either is not a SRFI 128 comparator,”
> or something similar.
>
>
> * Another agreement issue: “With the incoming and outgoing edges if
> they are not a proper list.”  There are a few more of these scattered
> throughout the document.
>
>
> * ‘build-graph’: With regard to all of these irritants, how can you
> tell (except by reading the error message) which of the 8 cases caused
> the exception to be raised?  Knowing the answer to this question is
> either important enough to warrant adding fine-grained condition
> subtypes, or not important enough to specify so fine-grainedly.

I had a think about this quite a bit… Here's what I've come up with.

The main error cases I think are as follows, primarily for build-graph,
but it's largely the same for graph-embed &c.
1) Top-level errors when constructing a graph, namely the two comparators
   aren't comparators
2) A given node context is malformed in that it doesn't have a list of
   pairs of incoming/outgoing edges, the index is not an integer
3) The node context's label is not valid given the graph's node label comparator
4) An incoming edge refers to a non-existent source node
5) An outgoing edge refers to a non-existent target node
6) An incoming edge's label is not valid given the graph's edge label comparator
7) An outgoing edge's label is not valid given the graph's edge label comparator

All of these are currently defined as different assertion violations with
particular irritants… I think we can model the existing behaviour with
just a few (compound) conditions:

a) An &graph condition (or violation) which consists of an erroneous node context
   and a given graph. This graph might be empty (it depends how we model something
   like build-graph wehere there is no graph to start with).
b) A &source edge condition which indicates an error in the incoming edges
c) A &target edge condition which indicates an error in the outgoing edges
d) A &node condition which indicates an error in a node index
e) A &label condition which indicates an error in a node *or* edge label

Case 1: I think this can be kept simply as an assertion violation
Case 2: I think this should be a bare &graph condition without any more elaboration
Case 3 (bad node label): &graph + &node + &label
Case 4 (invalid source node): &graph + &source + &node (not sure if this is ideal)
Case 5 (invalid target node): &graph + &target + &node
Case 6 (invalid source label): &graph + &source + &label
Case 7 (invalid target label): &graph + &source + &label

Here's what I currently have:
https://codeberg.org/dguthrie/scheme-fgl/src/branch/srfi-287bis/srfi/:287/graph-conditions.scm
It currently doesn't give &source or &target a field (like an irritant) as it has dual use for labels and indices, which we get from &node and &label. I've not modified the library yet to use these and that might take a bit of time to flesh out.

> * Missing words: “An assertion violation is raised with *pair* as
> irritant [if it] is not a proper list.” Also, rename ‘pair’ to ‘list’,
> since it must be one.

I used pair as that's in the R6RS convention, but not list, but I will just add
"list" in the SRFI document.

> * Typo in ‘graph-contains?’: “Procedure which tests whether graph
> contains a node in[d]exed at k.”
>
> “The second case returns #t if and only if there is a node at k and
> that it has label label.” Read “The second case returns #t if and only
> if there is a node at k which has label *label*”.
>
>
> * ‘graph=?’: In what sense must the graphs’ comparators be the same?

It's eq? as that's what the SRFI 113 sample implementation did (and SRFI
128 didn't define a way to say whether two comparators are the same).
Is there more to it, i.e. is eq? too strong?

> * Is ‘graph-embed’ required to embed its context arguments in
> left-to-right order, or are other orders allowed?  Similar questions
> apply to the ‘insert’ & ‘delete’ procedures.

It's left-to-right, I'll clarify this where I can.

> * I think you can save a lot of text about invalid-type assertions if
> you add ‘src’, ‘tgt’, ‘label’, etc.  to the “Argument restrictions and
> conventions” section.
>
>
> * ‘graph-context’ is said to be faster than ‘graph-match’.  I think it
> would be very useful to implementers and users if this were quantified.
> What kind of running time should we be able to expect from the forms of
> this SRFI?  (This question is especially relevant to a graph library,
> given the traditional performance trade-offs involved in implementing
> graphs.)

It's faster as it doesn't have to remove every node and then every edge,
so it would be however long the underlying data structures take to remove
those. It's mainly fast as it just retrieves. This is not so rigorous and
I assumed it would be clear to readers, but maybe not.

> * The signature of ‘graph-fold’ has a missing close paren.
>
>
> * To each his own when it comes to identifiers, but I think “nlab-comp”
> (“node label comparator”!) and “elab-comp” are cryptic names indeed.
> “node-comparator” and “edge-comparator” seem just fine.
>
>
> Again, thanks.  I’ll keep reading.

Thanks for the comments, I really appreciate it.

Best,
Duncan