[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
overloading an existing operator in Guile
From: |
Damien Mattei |
Subject: |
overloading an existing operator in Guile |
Date: |
Tue, 3 Oct 2023 11:13:30 +0200 |
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
- overloading an existing operator in Guile,
Damien Mattei <=