David Kastrup <d...@gnu.org> writes:

> GOOPS was supposed to cause quite a performance hit with Guile 1.8 when
> used extensively.  It wasn't supposed to do this with Guile 2+ so
> something like this should be feasible, also for other types:
>
> #(use-modules (oop goops))
>
> #(define <Moment> (class-of (ly:make-moment 0)))
>               
> #(define-method (+ (a <Moment>) (b <Moment>)) (ly:moment-add a b))
> #(define-method (- (a <Moment>) (b <Moment>)) (ly:moment-sub a b))
>
> #(display (- (ly:make-moment 3) (ly:make-moment 4) (ly:make-moment 2)))
>
> For those types where manipulation is frequent enough that we defined
> arithmetic (and possibly other) operators rather than ordinary functions
> in C++, there may be some point in doing the same in Scheme with
> generics.

Putting a bit more meat on what this may mean:

<https://gitlab.com/lilypond/lilypond/-/merge_requests/1404>

-- 
David Kastrup

Reply via email to