unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* overloading an existing operator in Guile
@ 2023-10-03  9:13 Damien Mattei
  2023-10-03  9:19 ` Jean Abou Samra
  2023-10-03 18:34 ` Maxime Devos
  0 siblings, 2 replies; 7+ messages in thread
From: Damien Mattei @ 2023-10-03  9:13 UTC (permalink / raw)
  To: guile-user

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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-10-03 19:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-03  9:13 overloading an existing operator in Guile Damien Mattei
2023-10-03  9:19 ` 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

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).