From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: exporting GOOPS generic functions, was: [ANN] guile-file-names 0.2 Date: Fri, 24 May 2019 22:14:42 -0400 Message-ID: <87imtzs2j6.fsf@netris.org> References: <87a7fmkbtv.fsf@invergo.net> <87y336b232.fsf@netris.org> <87mujekuzs.fsf@invergo.net> <87tvdjs50c.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="238223"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: guile-user@gnu.org To: Brandon Invergo Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat May 25 04:22:54 2019 Return-path: Envelope-to: guile-user@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 1hUMKh-000zp8-RZ for guile-user@m.gmane.org; Sat, 25 May 2019 04:22:51 +0200 Original-Received: from localhost ([127.0.0.1]:34803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUMKg-0000eG-AH for guile-user@m.gmane.org; Fri, 24 May 2019 22:22:50 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUMJw-0000am-8G for guile-user@gnu.org; Fri, 24 May 2019 22:22:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUMEg-0001Mw-UW for guile-user@gnu.org; Fri, 24 May 2019 22:16:39 -0400 Original-Received: from world.peace.net ([64.112.178.59]:37152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hUMEg-0001Mc-RO for guile-user@gnu.org; Fri, 24 May 2019 22:16:38 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hUMEf-0007Lq-GC; Fri, 24 May 2019 22:16:37 -0400 In-Reply-To: <87tvdjs50c.fsf@netris.org> (Mark H. Weaver's message of "Fri, 24 May 2019 21:21:12 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.112.178.59 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:15493 Archived-At: Hello again, > Brandon Invergo writes: > >> I can try something like this: >> >> (let ((old-absolute-file-name? absolute-file-name?)) >> (define-generic absolute-file-name?) >> (define-method (absolute-file-name? (f )) >> (proper-list? (route f))) >> (define-method (absolute-file-name? (f )) >> (old-absolute-file-name? f))) >> >> But that strangely gives me this upon compiling the module: >> >> While compiling expression: >> Unbound variable: absolute-file-name? >> >> I'm not sure what to make of that. A compile-time error, but why? > > It's because you tried to export a binding that doesn't exist at the > top-level of your module. I should explain more clearly what happened here. The short answer is: When you export a variable, it immediately shadows any imported bindings with the same name. The longer answer is that before a variable can be exported, we first need a variable object to add to the public interface. If you export a variable before it has been defined (the usual case), Guile allocates a fresh variable object and immediately adds it to the local module table, although it marks the variable as "unbound", which essentially means that the variable pretends not to exist. However, the existence of this "unbound" variable *does* have the effect of hiding any imports with the same name. Mark