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: Tue, 17 Oct 2017 21:23:28 -0200

Hi Andrew,

        Lets try to keep our conversation about this o the list, others may 
benefit
        from it, and/or help us ...

> Thanks for your feedback on this. It certainly resolved my issue.

Welcome.

> Can you point me to documentation on this? I read through the Guile info
> pages when trying to figure this out, but I couldn't figure it out.
> ...

No, there is no 'good' documentation neither recommendation(s) about 'generic
functions and the module system' in guile's manual - I mean 'no good' in my 
opinion,
but this is 'relative', and besides, some guilers are opposed to these
recommendations I always 'offer', but here they are:

1]      better preventing then curing:  when you define a module that use goops,
        always use

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

2]      unless you really know what you are doing, never call define-generic
        yourself

3]      always use #:export for class names, and make sure class names are
        unique (guile will warn you if not, at import time, so rename if you
        have conflict, never use twice the same class name in diff modules 
(unless
        you really know what you're doing))

4]      always use g-export for (and only for) getters, setters, accessors and
        methods

        
https://git.savannah.gnu.org/cgit/guile-cv.git/tree/cv/support/g-export.scm

5]      remember, while you are developing and testing your code, you have to 
add
        'merge-generics to the default-duplicate-binding-handler in the repl as 
well,
        _after_ you imported goops (in the repl):

        ,use (oop goops)
        (default-duplicate-binding-handler
           '(merge-generics replace warn-override-core warn last))
        (use-modules (yourmod1) (yourmod2))

With these recommendations, you actually 'mimic' [1] the CLOS specification, 
which
states that anything related to CLOS lands in a specific package, visible to all
others.

David

[1]     mimic because unlike CLOS, a generic function in a guile module will
        only contain methods that comes from that module and the one it
        imports, but not (necessarily) all methods for that name (unless the 
module
        imports all the others that define a method for that name of course)

Attachment: pgp_9_tnh9WSs.pgp
Description: OpenPGP digital signature


reply via email to

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