From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: Modules and GOOPS Date: Sat, 30 Jul 2016 23:35:44 -0300 Message-ID: <20160730233544.4a1330b9@capac> References: <20160728181425.5f167237@capac> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/zZZJuvNE/TtlKA+lfSuOWTQ"; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1469932637 29963 80.91.229.8 (31 Jul 2016 02:37:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 31 Jul 2016 02:37:17 +0000 (UTC) Cc: guile-user@gnu.org To: Kovacsics =?UTF-8?B?UsOzYmVydA==?= Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Jul 31 04:37:03 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTgcg-0007k7-O1 for guile-user@m.gmane.org; Sun, 31 Jul 2016 04:37:02 +0200 Original-Received: from localhost ([::1]:38171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTgcb-0004eM-0r for guile-user@m.gmane.org; Sat, 30 Jul 2016 22:36:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTgcB-0004eG-VO for guile-user@gnu.org; Sat, 30 Jul 2016 22:36:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTgc7-00008U-Ml for guile-user@gnu.org; Sat, 30 Jul 2016 22:36:30 -0400 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:32948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTgc7-00006x-DH for guile-user@gnu.org; Sat, 30 Jul 2016 22:36:27 -0400 Original-Received: from localhost (unknown [192.168.0.2]) by maximusconfessor.all2all.org (Postfix) with ESMTP id BFBF0A04C114; Sun, 31 Jul 2016 04:35:57 +0200 (CEST) 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 LaSp8mZ-10sJ; Sun, 31 Jul 2016 04:35:53 +0200 (CEST) Original-Received: from capac (unknown [177.133.154.95]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id AC89DA04C0F7; Sun, 31 Jul 2016 04:35:52 +0200 (CEST) In-Reply-To: X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; 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-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:12809 Archived-At: --Sig_/zZZJuvNE/TtlKA+lfSuOWTQ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello, > First, thank you for your detailed answer! Welcome > So what is the right approach when I'm implementing textbook data > structures (rather than want to use the given ones, for learning > reasons) and want to implement a set. On this set, I want to write a > method "closure" that computes all the elements of the set given a > ... I won't have time to help you to design the all thing, but i can review small and complete (no ...) code snipset. The code below is incomplete. > ; =3D > (define-module (sets set) > #:use-module (oop goops) > #:export ( add ... closure)) >=20 > (define-class ()) >=20 > (define-generic add) > ... >=20 > (define-method (closure (set ) (function )) > ... contains? ... add ... ) this is indeed not a very good design, imo: the fact that your is an = 'empty' class, and with no applicable methods for the all the methods it calls in c= losure, are the symptoms, imo, that this is not a good design > ; =3D > (define-module (sets red-black-tree) > #:use-module (oop goops) > #:use-module (sets set) > #:export ()) >=20 > (define-class ()) >=20 > (define-method (add (tree )) > ...) I can only give an opinion, and it is only an opinion, if you provide full = code snipset: and your add method lacks an argument to add :) > So I could move the add, etc, methods out into another module, if that > is the way to do it Nope, I did not say that, I did say that if you want to manually define gen= eric functions, then do it in a separate module, and imports that module when necessary. Although not strictly necessary technically speaking, we generally define m= ethods in the same module as the one where the class of its first argument (used to d= ispatch) is defined. Just look at some of the clutter examples (links i previous ema= il)... > Guile will complain with "unbound variable: add". But this is a very > classes-contain-methods approach and given what you said, makes me > think that I'm doing this wrong thing. The fact that you manually define the generic function "add" gives the 'ill= usion' the design is good, but in fact, (add (make ) ) will fail with no applicable method, which imo, is a sign that the=C2=ACthis design is not go= od. The fact that the GF definition is in the (sets set) module does not make t= he design any better. If you persist in manually defining GF, do it in another module= , that all other module which needs them imports of course ... David. --Sig_/zZZJuvNE/TtlKA+lfSuOWTQ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXnWQAAAoJEPN0/ZOjBXrXk5QH/1wDDPf0bxNK5nHWwIkz+HxK NG9CUlGd+/B1PAMiQ4TEApGTJb5kyMUVo5A0hDvdTZyZozawn7kPbSYw7nIHPWOB CIitiplcmPiCkfrrA1xB+NALZjy2gHzcJ1905ZHoH2adZgh5xf5xN21V0W8CSGBP bse4F7OfGomKpYIbtE/67BoLzCEaGfwTvA1KJKLnk4qIn/1Q0YOsyTguwszPjqd+ WNxACR8VyrcP0azXujEfXrxQyKECKW+fL6Koiht23fD4d+PhwoQJcffWls0oRb8/ cUKHbILePuaTok8jtugWCC3jqGV8p2Am77idC4y78fM3MqciCtMMLkGEbQVDBdE= =/1H3 -----END PGP SIGNATURE----- --Sig_/zZZJuvNE/TtlKA+lfSuOWTQ--