bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37461: define-generic doesn't promote equal? to generic


From: Rob Browning
Subject: bug#37461: define-generic doesn't promote equal? to generic
Date: Sat, 28 Sep 2019 12:31:24 -0500

Mikael Djurfeldt <address@hidden> writes:

> You see, I was under the impression that primitive-generic capability had
> been removed for equal?. It has not. It's only the printed representation
> which has changed.

Ahh, right -- that confused me at first too.

> One way to view this is that the dispatch of primitive-generics is
> partially constrained.

Understood -- It'd be nice if the expectations were documented a bit
more clearly.  I'd be happy to propose something, assuming we can
determine what's appropriate, i.e. what Guile really intends to promise.

It sounds like:

  - This might need adjustment:

      8.6.2 Extending Primitives
      --------------------------

      Many of Guile's primitive procedures can be extended by giving them a
      generic function definition that operates in conjunction with their
      normal C-coded implementation.  When a primitive is extended in this
      way, it behaves like a generic function with the C-coded implementation
      as its default method.

    In particular, it sounds like the C-coded implementation actually
    takes precedence; it doesn't act like a normal default method.

    I suppose in practice, unless the behavior of the primitive-generic
    is very well specified, it might be best to avoid specializations
    for anything other than new types (that you're responsible for).
    Otherwise future changes might fairly mysteriously break things.

  - We're unsure whether define-generic is intended to do anything to a
    primitive generic, but if we can figure that out, I can adjust the
    define-generic documentation:

       -- syntax: define-generic symbol
           Create a generic function with name SYMBOL and bind it to the
           variable SYMBOL.  If SYMBOL was previously bound to a Scheme
           procedure (or procedure-with-setter), the old procedure (and
           setter) is incorporated into the new generic function as its
           default procedure (and setter).  Any other previous value,
           including an existing generic function, is discarded and replaced
           by a new, empty generic function.

    and might also mention the issue in the define-method docs.

Thanks
-- 
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]