[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should we be touching goops?

From: David Kastrup
Subject: Re: Should we be touching goops?
Date: Sat, 04 Jun 2022 00:56:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Jean Abou Samra <> writes:

> Le 03/06/2022 à 02:32, David Kastrup a écrit :
>> 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.
> Nice! I wasn't aware that GOOPS had become faster
> in Guile 2, nor even that it supported smob types.
> I had stayed in the conception that it was a "don't
> use" module.
> I'd be in favor of doing this. It will ease writing
> operations on moments and such. What other types could
> use it? Moment and Duration stand as obvious candidates.

I don't think Duration makes a good candidate for arithmetic (you could
implement 2*3/2 as (* (ly:make-duration 1) 3/2) instead of
(ly:make-duration 1 0 3/2) but it seems somewhat contrived.

Pitch would make more sense (there are pitch differences).

David Kastrup

reply via email to

[Prev in Thread] Current Thread [Next in Thread]