Dan Eble <[email protected]> writes:
> ASSIGN_EVENT_ONCE(cur, new) does this:
>
> - if cur is nullptr: assign cur = new, return true
> - if *cur and *new are equal: quietly return false
> - if *cur and *new are unequal: warn and return false
>
> Would a Scheme analog of ASSIGN_EVENT_ONCE be used like this,
>
> (let ((my-foo-event #f))
> ;; . . .
> (listeners
> ((foo-event this-engraver event)
> (if (ly:set-event-once! my-foo-event event)
> ;; my-foo-event event has been set: handle it
>
> or am I thinking too much like a C++ programmer?
ASSIGN_EVENT_ONCE outputs a warning, doesn't it? A natural way of
representing this (though with a loss of choosing how to handle spurious
events) would be
(listeners
((foo-event this-engraver event #:once)
;; event has been seen the first time: handle it
Now how this would be actually implemented: that's a different question
altogether. make-engraver could conceivably handle this (though it
currently is a very superficial macro and would need to get smarter) by
inserting the equivalent of your code, or it could just use lambda*
instead of lambda and the generated callback could be smarter.
Yes, this is a lot of hand-waving for a simple question...
--
David Kastrup