From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: divoplade Newsgroups: gmane.lisp.guile.user Subject: Implementing a "write" method for self-evaluating objects (by equal?) Date: Thu, 17 Sep 2020 22:02:31 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27210"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.34.2 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Sep 17 22:11:45 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJ0Ft-0006ys-1n for guile-user@m.gmane-mx.org; Thu, 17 Sep 2020 22:11:45 +0200 Original-Received: from localhost ([::1]:45900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJ0Fs-0001WD-28 for guile-user@m.gmane-mx.org; Thu, 17 Sep 2020 16:11:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ07Y-0002Hs-3N for guile-user@gnu.org; Thu, 17 Sep 2020 16:03:13 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:40263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJ07U-0006rY-OP for guile-user@gnu.org; Thu, 17 Sep 2020 16:03:07 -0400 X-Originating-IP: 86.194.83.229 Original-Received: from divoplade.home (lfbn-lyo-1-1007-229.w86-194.abo.wanadoo.fr [86.194.83.229]) (Authenticated sender: d@divoplade.fr) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 44CA12000B for ; Thu, 17 Sep 2020 20:02:54 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.200; envelope-from=d@divoplade.fr; helo=relay7-d.mail.gandi.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/17 16:02:55 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16917 Archived-At: Hello guile users, In the manual, I read: (define-method (write (file ) port) (format port "#< ~s ~a>" (name file) (fd file))) So it is possible to define a write method for foreign objects (and more generally GOOPS classes). My question is: why use such a bizarre syntax with # and #:fd ~a #:name ~s)" (fd file) (name file)) This is a little more verbose, but at least the syntax explains how to construct the value. There must be some cases where it would not be possible (such as pointers to opaque data that do not have a constructor...), and it would break if for instance "make" is renamed to something else. However, if I were to implement a write method, I would use this, a textual representation of a constructor that would produce the same value (according to equal?).