unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: David Pirotte <david@altosw.be>
To: bug-guile@gnu.org
Subject: goops: default-duplicate-binding-handler 'does not work' when global [i.e. in init.scm]
Date: Sat, 20 Aug 2011 19:56:14 -0300	[thread overview]
Message-ID: <20110820195614.36a5b4a2@rascar> (raw)

[-- Attachment #1: Type: text/plain, Size: 2351 bytes --]

Hello,

I've noticed that the following attached code [slightly modified since my previous
related message] only works if the third module also specify:

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

	;; [which I deleted from the define-module precisely so to raise the bug

This means that the following form

	(default-duplicate-binding-handler
	  '(merge-generics replace warn-override-core warn last))

which I added to my init.scm file, does not produce the expected global goops
behavior I think it should [unless I missed something]

As a consequence, if you use-modules 'manually in the repl, then depending on the
order of your use-modules sequence, you also face this same bug [since the repl only
depend on the global default-duplicate-binding-handler setting. Here is a track of 2
sessions, to illustrate [which I edited manually after pasting here to reduce to
essential input/output]

	[Note: of course you'll have to add the above
	default-duplicate-binding-handler call in your init.scm in order to reproduce]

Thanks,
David

;;;
;;; The first session
;;;

david@rascar:~/alto/projects/kise 23 $ guile
GNU Guile 2.0.2.49-6b1c5 ...
scheme@(guile-user)> (default-duplicate-binding-handler)
(default-duplicate-binding-handler)
$1 = (merge-generics replace warn-override-core warn last)
scheme@(guile-user)> (use-modules (mg-1)
	     (mg-2))
(define widget (make-widget-b))
(dialog widget)
WARNING: (guile-user): `dialog' imported from both (mg-1) and (mg-2)
$2 = dialog-b
scheme@(guile-user)> ,q

;;;
;;; The second
;;;

david@rascar:~/alto/projects/kise 24 $ guile
scheme@(guile-user)> (use-modules (mg-2)
	     (mg-1))
(define widget (make-widget-b))
(dialog widget)
WARNING: (guile-user): `dialog' imported from both (mg-2) and (mg-1)
ERROR: In procedure scm-error:
ERROR: No applicable method for #<<accessor> dialog (1)> in call (dialog #<<widget-b> 8677a80>)

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt

In oop/goops/dispatch.scm:
    231:9  1 (cache-miss #<<accessor> dialog (1)> (#<<widget-b> 8677a80>))
In unknown file:
           0 (scm-error goops-error #f "No applicable method for ~S in call
           ~S" (#<<accessor>…> …) …)

[-- Attachment #2: mg-1.scm --]
[-- Type: text/x-scheme, Size: 273 bytes --]


(define-module (mg-1)
  :use-module (oop goops)

  :export (<widget-a>
	    dialog

	    make-widget-a
	    ))


(define-class <widget-a> ()
  (dialog :accessor dialog :init-keyword :dialog :init-value #f))

(define (make-widget-a)
  (make <widget-a> :dialog 'dialog-a))


[-- Attachment #3: mg-2.scm --]
[-- Type: text/x-scheme, Size: 622 bytes --]


(define-module (mg-2)
  :use-module (oop goops)

  :export (<widget-b>
	    dialog

	    make-widget-b
	    ))


(define-class <widget-b> ()
  (dialog :accessor dialog :init-keyword :dialog :init-value #f))

(define (make-widget-b)
  (make <widget-b> :dialog 'dialog-b))



#!

(use-modules (macros push))
(push! "/usr/local/share/guile/alto/2.0/tests"
       %load-path)

;;;
;;; Test multiple imports - 1
;;;

(use-modules (mg-1)
	     (mg-2))
(define widget (make-widget-b))
(dialog widget)


;;;
;;; Test multiple imports - 2
;;;

(use-modules (mg-2)
	     (mg-1))
(define widget (make-widget-b))
(dialog widget)


!#

[-- Attachment #4: mg-3.scm --]
[-- Type: text/x-scheme, Size: 674 bytes --]


(define-module (mg-3)
  :use-module (ice-9 format)
  :use-module (oop goops)

  :use-module (mg-1)
  :use-module (mg-2)

  :export (a
	   b
	   letstry))


(define a (make <widget-a>))
(define b (make <widget-b>))

(define (letstry)
  (format #t "Dialog a: ~S~%" (dialog a))
  (format #t "Dialog b: ~S~%" (dialog b)))


#!

(use-modules (macros push))
(push! "/usr/local/share/guile/alto/2.0/tests"
       %load-path)

(use-modules (mg-3))
(letstry)

;;;
;;; now in init.scm
;;; (default-duplicate-binding-handler
;;;   '(merge-generics replace warn-override-core warn last))


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

!#

             reply	other threads:[~2011-08-20 22:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-20 22:56 David Pirotte [this message]
2011-08-27 13:02 ` goops: default-duplicate-binding-handler 'does not work' when global [i.e. in init.scm] Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110820195614.36a5b4a2@rascar \
    --to=david@altosw.be \
    --cc=bug-guile@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).