unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Tomas Volf <~@wolfsden.cz>
To: guile-user@gnu.org
Subject: How to globally replace core binding?
Date: Sun, 26 Nov 2023 18:42:44 +0100	[thread overview]
Message-ID: <ZWODlBbqtbuGqtyy@ws> (raw)

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

Hello,

I would like to replace a core binding.  I know that I can define a module like
this:

    (define-module (foo))
    (define-public (copy-file a b)
      (display "TODO: implement file copy\n"))

And I can later use it

    scheme@(guile-user)> ,use (foo)
    scheme@(guile-user)> (copy-file 'a 'b)
    TODO: implement file copy

But!  I would like to replace the copy-file globally, for all modules, without
the need to explicitly import it.  I guess I want something in the spirit of the
`install-suspendable-ports!', so that I could do something like:

    scheme@(guile-user)> ,use (foo)
    scheme@(guile-user)> (install-better-copy-file!)

I could patch the Guile itself, but I would strongly prefer to avoid that, for
obvious reasons.  So, is it possible to achieve what I want, and if so, how?

Thank you and have a nice day,
Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

             reply	other threads:[~2023-11-26 17:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-26 17:42 Tomas Volf [this message]
2023-11-28  0:51 ` How to globally replace core binding? Maxime Devos
2023-11-28  1:37   ` Tomas Volf
2023-11-28  1:57     ` Maxime Devos

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=ZWODlBbqtbuGqtyy@ws \
    --to=~@wolfsden.cz \
    --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).