guile-user
[Top][All Lists]
Advanced

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

Re: Problem merging generics across modules


From: David Pirotte
Subject: Re: Problem merging generics across modules
Date: Fri, 13 Oct 2017 11:35:09 -0300

Hi again,

> (define-module (project a)
>   #:use-module (oop goops)  
>   #:use-module (ice-9 r5rs)
>   #:duplicates (merge-generics)
>   #:export (equal?)

> but this doesn't seem to do anything.

Because that was not the source of your problem, see my previous email.

Although in theory merge-generics is only needed when you import more then one 
module
that define the 'same' generic function, I personally recommend you to add the 
option
in any modules that use goops, unless you really know what you are doing:

        this is because as time goes, you may rearrange your modules, import
        others ... and forget that more then one defined a generic function, 
and ...
        bang! (and these bugs are among the most diffcult to track down and 
debug

Note that you probably want more then just 'merge-generics, and prefer to 
extend the
default set:

        scheme@(guile-user)> (default-duplicate-binding-handler)
        $10 = (replace warn-override-core warn last)

So this gives you:

  #:duplicates (merge-generics
                replace
                warn-override-core
                warn
                last)

Also note that you have to set this in the repl as well, if you import more 
then one
module defining the 'same' generics ...:

        (default-duplicate-binding-handler
           '(merge-generics replace warn-override-core warn last))
        $11 = (#<<generic> merge-generics (3)> #<procedure replace (module name 
int1 val…> …)
        scheme@(guile-user)> (default-duplicate-binding-handler)
        $12 = (merge-generics replace warn-override-core warn last)

David

Attachment: pgpkNyYBAWJix.pgp
Description: OpenPGP digital signature


reply via email to

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