unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Brandon Invergo <brandon@invergo.net>
Cc: guile-user@gnu.org
Subject: Re: exporting GOOPS generic functions, was: [ANN] guile-file-names 0.2
Date: Fri, 24 May 2019 22:14:42 -0400	[thread overview]
Message-ID: <87imtzs2j6.fsf@netris.org> (raw)
In-Reply-To: <87tvdjs50c.fsf@netris.org> (Mark H. Weaver's message of "Fri, 24 May 2019 21:21:12 -0400")

Hello again,

> Brandon Invergo <brandon@invergo.net> 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 <file-name>))
>>         (proper-list? (route f)))
>>       (define-method (absolute-file-name? (f <string>))
>>         (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



      reply	other threads:[~2019-05-25  2:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16  9:06 [ANN] guile-file-names 0.2 Brandon Invergo
2019-05-16 20:01 ` Mark H Weaver
2019-05-16 20:06   ` Mark H Weaver
2019-05-17  8:36     ` Brandon Invergo
2019-05-22 22:03   ` exporting GOOPS generic functions, was: " Brandon Invergo
2019-05-25  1:21     ` Mark H Weaver
2019-05-25  2:14       ` Mark H Weaver [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87imtzs2j6.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=brandon@invergo.net \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).