Re: overloading an existing operator in Guile

2023-10-03 Thread Damien Mattei
i agree with you all but there is a misunderstanding of what i'm currently doing. I'm not making + that append vectors a part of Scheme+, it is just for a personal program that i want to overload it. This will never be in Scheme+. (even if python use + for appending list, and list in python are ha

Re: overloading an existing operator in Guile

2023-10-03 Thread Jean Abou Samra
> Le 3 oct. 2023 à 20:35, Maxime Devos a écrit : > > It's explained in ‘(guile)Methods and Generic Functions’ how to do this. > > However, I very much recommend not doing this in your situation. +1. I'd recommend only implementing a method foo on a type bar if you are in control of either fo

Re: overloading an existing operator in Guile

2023-10-03 Thread Maxime Devos
Op 03-10-2023 om 11:13 schreef Damien Mattei: 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 (o

Re: overloading an existing operator in Guile

2023-10-03 Thread Damien Mattei
solution: scheme@(guile-user)> (define-method (+ (x ) (y )) (vector-append x y)) ;;; :11:46: warning: possibly unbound variable `vector-append' scheme@(guile-user)> (use-modules (srfi srfi-43)) scheme@(guile-user)> (+ 2 3) $3 = 5 scheme@(guile-user)> (+ #(1 2 3) #(4 5)) $4 = #(1 2 3 4 5) scheme@(

Re: overloading an existing operator in Guile

2023-10-03 Thread Damien Mattei
thank you i understand i must overload + the usual way in class scheme@(guile-user)> $2 = #< 104a6e380> about the described problem this should not be a problem because - as no sense in term of concatanate On Tue, Oct 3, 2023 at 11:19 AM Jean Abou Samra wrote: > > > > Le 3 oct. 2023 à 11:14,

Re: overloading an existing operator in Guile

2023-10-03 Thread Jean Abou Samra
> Le 3 oct. 2023 à 11:14, Damien Mattei a écrit : > > is it possible to overload an existing operator in Guile? Yes, but it's a bit buggy. See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64508