From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.bugs Subject: GOOPS - metaclass with extra-slots made trying to define a getter, a setter or an accessor will raise an exception Date: Wed, 23 Jan 2019 23:19:39 -0200 Message-ID: <20190123231939.0a6115e6@capac> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/0RnbqR+A..mrpnw3ro8uSHw"; protocol="application/pgp-signature" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="168912"; mail-complaints-to="usenet@blaine.gmane.org" To: , guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jan 24 02:21:26 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmTht-000hqn-Qm for guile-devel@m.gmane.org; Thu, 24 Jan 2019 02:21:25 +0100 Original-Received: from localhost ([127.0.0.1]:44564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmThs-0008Bn-Ig for guile-devel@m.gmane.org; Wed, 23 Jan 2019 20:21:24 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmTgR-00072z-CY for guile-devel@gnu.org; Wed, 23 Jan 2019 20:19:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmTgQ-0006hV-Ea for guile-devel@gnu.org; Wed, 23 Jan 2019 20:19:55 -0500 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:53366) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gmTgL-0006d4-Sd; Wed, 23 Jan 2019 20:19:50 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by maximusconfessor.all2all.org (Postfix) with ESMTP id 00D3B1BE00E6; Thu, 24 Jan 2019 02:19:47 +0100 (CET) Original-Received: from maximusconfessor.all2all.org ([127.0.0.1]) by localhost (maximusconfessor.all2all.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MNstDJac7BCz; Thu, 24 Jan 2019 02:19:46 +0100 (CET) Original-Received: from capac (unknown [177.98.10.100]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id C6ADE1BE00E0; Thu, 24 Jan 2019 02:19:45 +0100 (CET) X-Mailer: Claws Mail 3.17.2 (GTK+ 2.24.32; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 79.99.200.102 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.lisp.guile.devel:19810 gmane.lisp.guile.bugs:9297 Archived-At: --Sig_/0RnbqR+A..mrpnw3ro8uSHw Content-Type: multipart/mixed; boundary="MP_/=Fbyds6quu6u=hiWGWlrem1" --MP_/=Fbyds6quu6u=hiWGWlrem1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, Using a metaclass that defines extra-slots, will only work if the extra-slo= ts are made 'exclusively' using the expression: (make #:name name) If one tries to pass a setter, a getter or an accessor, it raises an except= ion. Attached a code snipset to reproduce the error: drop it anywhere and load i= t, then enter ',bt' to see the backtrace ... I pasted the error I get, below my signature, so one can compare I am using Guile 2.2.4.1-cdb19 As you can see, the error is triggered by (oop goops) add-method! - called = by=20 compute-slot-accessors - which complains that the accessor name (or getter = or setter name) is not a valid generic function. Though I think it should be automatically created if it does not exists, I = also tried to create it - which you may try uncommenting line 20 and 21 of the c= ode snipset - but that didn't solve the problem. Thanks, David scheme@(guile-user)> (load "/usr/alto/projects/g-golf/foo-acc.scm") ;;; note: source file /usr/alto/projects/g-golf/foo-acc.scm ;;; newer than compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.A/= usr/alto/projects/g-golf/foo-acc.scm.go ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /usr/alto/projects/g-golf/foo-acc.scm ;;; compiled /home/david/.cache/guile/ccache/2.2-LE-8-3.A/usr/alto/projects= /g-golf/foo-acc.scm.go scm-error!x Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(foo-acc) [1]> ,bt In ice-9/boot-9.scm: 2316:4 7 (save-module-excursion _) 3835:12 6 (_) In /usr/alto/projects/g-golf/foo-acc.scm: 36:0 5 (_) In oop/goops.scm: 3032:4 4 (_ _ . _) 2925:2 3 (_ #< 563eb337f360> _) In srfi/srfi-1.scm: 640:9 2 (for-each # (#< x 563eb337f=E2=80=A6> =E2=80=A6)) In oop/goops.scm: 2730:9 1 (_ #< x 563eb337f1b0>) In unknown file: 0 (scm-error goops-error #f "~S is not a valid generic function"= (!x) ()) scheme@(foo-acc) [1]>=20 --MP_/=Fbyds6quu6u=hiWGWlrem1 Content-Type: text/x-scheme Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=foo-acc.scm (define-module (foo-acc) #:use-module (oop goops) #:export ( )) (define %props '("x" "y")) (define-class ()) (define (compute-extra-slots props slots) (map (lambda (prop) (let ((name (string->symbol prop)) (acc (string->symbol (string-append "!" prop))) #;(gen (make #:name acc))) #;(module-define! (current-module) acc gen) #;(make #:name name) #;(make #:name name #:getter name) (make #:name name #:accessor acc))) props)) (define-method (compute-slots (class )) (let* ((slots (next-method)) (extra (compute-extra-slots %props slots))) (slot-set! class 'direct-slots (append (slot-ref class 'direct-slots) extra)) (append slots extra))) (define-class () #:metaclass ) --MP_/=Fbyds6quu6u=hiWGWlrem1-- --Sig_/0RnbqR+A..mrpnw3ro8uSHw Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhCJlRZtBM3furJHe83T9k6MFetcFAlxJEqsACgkQ83T9k6MF etc7BwgAm4VDw9kzp+bPBsbXcpnP5cwHzk5MVqvP7I54w9qEaVFmYHgSPHWFkusH JVHalbVJfolA5N7ZPwDwFXjoXB3olbi+EdKeoLGUAvmGRLRmHVKv7w4I/X+JL3tK ORpDwt6NOSfgA5BL/r+JFo121AYNrpRYdntC809r4P74zO0ancbbvKml0kesGAJ8 hP0SOQr4vycuSUege86kZolrLaorwu1DxBG+BG+3sUFsshDE6oIIg7dtAqSYmpB4 d1fsqrcl0vqgtY9D/qpBrKfTb6oiEhoMVlriHCTgZoGVVJUrDCuzLsphlnaQeLnH B+WuIIpXnfJ45rmqvoPbucaQhfcLTA== =/KNs -----END PGP SIGNATURE----- --Sig_/0RnbqR+A..mrpnw3ro8uSHw--