unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Damien Mattei <damien.mattei@gmail.com>
To: guile-user <guile-user@gnu.org>
Subject: overloading an existing operator in Guile
Date: Tue, 3 Oct 2023 11:13:30 +0200	[thread overview]
Message-ID: <CADEOaddS5BKnzX2on7ptOJY90dWHKn7cw0wBEpbMqRe09PJTzQ@mail.gmail.com> (raw)

hello,
is it possible to overload an existing operator in Guile?

example overload + to concatenate vectors.

for example in Scheme (+ i admit) i can do :
; first stage overloading
(define-overload-existing-operator +)

; second stage overloading
(overload-existing-operator + vector-append (vector? vector?))

and use it like that:
> (+ #(1 2 3) #(4 5 6))
'#(1 2 3 4 5 6)
> (+ #(1 2 3) #(4 5) #(6 7 8 9))
'#(1 2 3 4 5 6 7 8 9)
> {#(1 2) + #(3) + #(4 5 6)}
'#(1 2 3 4 5 6)

is it possible and how to do it using GOOPS (guile object oriented
programming system) , i already did some sort of thing with new object
, but not with an existing operator like + that apply to numbers only.

Regards,
Damien



             reply	other threads:[~2023-10-03  9:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03  9:13 Damien Mattei [this message]
2023-10-03  9:19 ` overloading an existing operator in Guile Jean Abou Samra
2023-10-03 10:33   ` Damien Mattei
2023-10-03 18:24     ` Damien Mattei
2023-10-03 18:34 ` Maxime Devos
2023-10-03 18:41   ` Jean Abou Samra
2023-10-03 19:01     ` Damien Mattei

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=CADEOaddS5BKnzX2on7ptOJY90dWHKn7cw0wBEpbMqRe09PJTzQ@mail.gmail.com \
    --to=damien.mattei@gmail.com \
    --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).