From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.devel Subject: #:export should not 'hide' imported functionality Date: Wed, 24 Dec 2014 16:01:46 -0200 Message-ID: <20141224160146.555eaf07@capac> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/ao9KW8CxiDBBZy0nttykXaQ"; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1419444152 29374 80.91.229.3 (24 Dec 2014 18:02:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Dec 2014 18:02:32 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Dec 24 19:02:26 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y3qGP-00011n-T9 for guile-devel@m.gmane.org; Wed, 24 Dec 2014 19:02:26 +0100 Original-Received: from localhost ([::1]:49171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3qGP-0003NN-EJ for guile-devel@m.gmane.org; Wed, 24 Dec 2014 13:02:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3qGL-0003NF-Q2 for guile-devel@gnu.org; Wed, 24 Dec 2014 13:02:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y3qGI-0003FN-Gb for guile-devel@gnu.org; Wed, 24 Dec 2014 13:02:21 -0500 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:44148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y3qGI-0003AD-8T for guile-devel@gnu.org; Wed, 24 Dec 2014 13:02:18 -0500 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id 42D3EA04C0FF for ; Wed, 24 Dec 2014 19:01:56 +0100 (CET) Original-Received: from maximusconfessor.all2all.org ([192.168.0.1]) by localhost (maximusconfessor.all2all.org [192.168.0.2]) (amavisd-new, port 10024) with ESMTP id 0Jpzo5el-ov0 for ; Wed, 24 Dec 2014 18:38:29 +0100 (CET) Original-Received: from capac (unknown [179.210.42.225]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id B641EA04C0C5 for ; Wed, 24 Dec 2014 19:01:48 +0100 (CET) X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 79.99.200.102 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17626 Archived-At: --Sig_/ao9KW8CxiDBBZy0nttykXaQ Content-Type: multipart/mixed; boundary="MP_/IJa/lYfK.Ffa=hH3vsxIunl" --MP_/IJa/lYfK.Ffa=hH3vsxIunl Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, [ writing a 'pure' guile/goops code, not using guile-gnome [ guile-clutter is left as an exercise :) In the attached code [image.scm], uncommenting line 43 [commenting line 49] would raise the following bug (1). Imo, it should not: the module system, #:export, should be goops 'aware' and not 'hide', as a side effect, imported generic functions and methods. Because #:export calls module-ensure-local-variable!, before anything else, a new get-with var is created, first unbound, later turned into a generic function with 1 applicable [locally defined] method only, hiding imported functionality the module relies on. Note that the initialize method redefinition is not even (re)exported, so we are talking about guile breaking the code it runs within the=20 module 'space' itself, which is not acceptable. Even though, as some guile maintainers think it should [i don't, but that's another subject], using #:export should indeed create a new generic function with the locally defined applicable method only, it should do so for export purposes, only, for modules that will use 'this one': it should not break upon execut= ing (get-with pixbuf), since (gnome gw gdk), imported, provides the functionali= ty it needs. If anyone is interested, see g-export [goops export] code [attached] I wro= te to circumvent this problem. Happy hacking, David ;; -- (1) the bug report ;;; compiling ./clus/image.scm ;;; compiled /home/david/.cache/guile/ccache/2.0-LE-8-2.0/usr/alto/projects= /clutter/1.12/clus/image.scm.go Backtrace: In ice-9/boot-9.scm: 157: 10 [catch #t # ...] In unknown file: ?: 9 [apply-smob/1 #] In ice-9/boot-9.scm: 63: 8 [call-with-prompt prompt0 ...] In ice-9/eval.scm: 432: 7 [eval # #] In clutter/1.12/toolbar: 81: 6 [main ("./toolbar" "-d")] In oop/goops.scm: 1553: 5 [# # = # ...] In clutter/1.12/clus/toolbar.scm: 141: 4 [# # ...] In oop/goops.scm: 1553: 3 [# # = # ...] In clutter/1.12/clus/image.scm: 82: 2 [# # ...] In oop/goops/dispatch.scm: 239: 1 [cache-miss #< get-width (1)> (#< 1e6fa00>)] In unknown file: ?: 0 [scm-error goops-error #f ...] ERROR: In procedure scm-error: ERROR: No applicable method for #< get-width (1)> in call (get-wid= th #< 1e6fa00>) david@capac:~/alto/projects/clutter/1.12 174 $=20 --MP_/IJa/lYfK.Ffa=hH3vsxIunl Content-Type: text/x-scheme Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=image.scm ;; -*- mode: scheme; coding: utf-8 -*- ;;;; Copyright (C) 2014 ;;;; Free Software Foundation, Inc. ;;;; This file is part of the guile-clutter examples set. ;;;; Guile-clutter examples set is free software: you can redistribute ;;;; it and/or modify it under the terms of the GNU General Public ;;;; License as published by the Free Software Foundation, either ;;;; version 3 of the License, or (at your option) any later version. ;;;; Guile-clutter examples set is distributed in the hope that it ;;;; will be useful WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;;; General Public License for more details. ;;;; You should have received a copy of the GNU General Public License ;;;; along with the guile-clutter examples set. If not, see ;;;; . ;;; Commentary: ;; <- stands for -> ;; clue clutter example ;; clues clutter examples set ;; clus clutter support ;;; Code: (define-module (clus image) #:use-module (ice-9 receive) #:use-module (oop goops) #:use-module (gnome-2) #:use-module (gnome gobject) #:use-module (gnome glib) #:use-module (gnome gw gdk) ;; gdk-pixbuf #:use-module (gnome clutter) #:use-module (clus utils) #:export ( #;get-width)) (g-export !filename !pixbuf get-width get-height get-size) (define-class () (filename #:accessor !filename #:init-keyword #:filename #:init-value #f) (pixbuf #:accessor !pixbuf #:init-keyword #:pixbuf #:init-value #f)) (define-method (initialize (self ) initargs) (next-method) (let ((pixbuf (gdk-pixbuf-new-from-file (!filename self)))) (set! (!pixbuf self) pixbuf) (set-data self (get-pixels pixbuf) (if (get-has-alpha pixbuf) 'rgba-8888 'rgb-888) (get-width pixbuf) (get-height pixbuf) (get-rowstride pixbuf)) self)) (define-method (get-width (self )) (get-width (!pixbuf self))) (define-method (get-height (self )) (get-height (!pixbuf self))) (define-method (get-size (self )) (let ((pixbuf (!pixbuf self))) (values (get-width pixbuf) (get-height pixbuf)))) --MP_/IJa/lYfK.Ffa=hH3vsxIunl Content-Type: text/x-scheme Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=g-export.scm ;; -*- mode: scheme; coding: utf-8 -*- ;;;; Copyright (C) 2014 ;;;; Free Software Foundation, Inc. ;;;; This file is part of the guile-clutter examples set. ;;;; Guile-clutter examples set is free software: you can redistribute ;;;; it and/or modify it under the terms of the GNU General Public ;;;; License as published by the Free Software Foundation, either ;;;; version 3 of the License, or (at your option) any later version. ;;;; Guile-clutter examples set is distributed in the hope that it ;;;; will be useful WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;;; General Public License for more details. ;;;; You should have received a copy of the GNU General Public License ;;;; along with the guile-clutter examples set. If not, see ;;;; . ;;; Commentary: ;; <- stands for -> ;; clue clutter example ;; clues clutter examples set ;; clus clutter support ;;; Code: (define-module (g-export) #:use-module (oop goops) #:export (module-g-export! g-export)) (define (module-g-export! m names) (unless (memq 'merge-generics (default-duplicate-binding-handler)) (display "Warning: you are using g-export [goops export, which re-expor= t defined names and should only be used for accessors, getters, setters and methods], but you did not ask to merge duplicate generic functions: unless you really know what you are doing, you should.\n" (current-output-port))) (let ((public-i (module-public-interface m))) (for-each (lambda (name) (let* ((internal-name (if (pair? name) (car name) name)) (external-name (if (pair? name) (cdr name) name)) (var (module-variable m internal-name))) (if var (module-add! public-i external-name var) (module-add! public-i external-name (module-ensure-local-variable! m internal-name))))) names))) (define-syntax-rule (g-export name ...) (eval-when (expand load eval) (call-with-deferred-observers (lambda () (module-g-export! (current-module) '(name ...)))))) --MP_/IJa/lYfK.Ffa=hH3vsxIunl-- --Sig_/ao9KW8CxiDBBZy0nttykXaQ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBAgAGBQJUmv+KAAoJEPN0/ZOjBXrXobYIAJkkWcCQvqWaqlBhl0dQcSCh bmxYu8bWGiJmZN/mlO+xA/gE/T4M6uRjk99WHrPZQu2SBHxqtb71yT7DenUttXDy Nh/LCDtVzKmtWx0vti990ovH7QCmpWJLe0LdAPtoZg76IYdd5kr8VexYRiA1yzpo eytokLdGVSqbdBoxlAokAaymUnor2Q82HbTK8noozvAShRFYO/DlX+x9pk5JibqO E13R1qnUAcX2vThOP18KcWqnzmuuRJmfMGReyrwLVETRntAgsJNXYbkXOI9xj90P kP2vjVt0ha1Y68FSud9T9JL1Dqrh+ybD7+c/gQbpXYEB8ogt7EJyXAUkMaJHxJg= =KHp5 -----END PGP SIGNATURE----- --Sig_/ao9KW8CxiDBBZy0nttykXaQ--