On 2024-10-04 03:59, David Kastrup wrote:
Saul Tobin <saul.james.to...@gmail.com> writes:
I can see duration vs. moment becoming a source of confusion, since these
are not the same type. I would expect a property named baseDuration to take
a value of type ly:duration?.
Yup, but a duration has structural properties (there are different
durations with the same length). That is not wanted here.
I agree with David. For this property, Duration's log and dots are just
as irrelevant as Moment's grace part.
This isn't one. What is more of an issue that a lot of properties
taking a ly:moment? should rather be taking an exact rational (because
they will never have grace parts), and the reason that they don't is
that early versions of Guile did not have exact rationals.
I am glad you joined the conversation, because I have been thinking
about how to allow setting a musical-length property to a number in the
ly code.
To avoid disrupting readers, I thought I might try continuing to store
the context property as a moment and support convert-on-set by having
the property's type predicate return the converted value in a new kind
of wrapper smob that marks it as a converted value rather than a plain
old truthy value. The C++ code would detect that and store the
converted value in lieu of the user-provided value. What do you think
of that?
If that seems like a bad idea for some reason, I guess I would skip it
and change musical-length? and positive-musical-length? to accept raw
numbers in addition to moments, change built-in functions like
ly:moment-main to accept numbers and treat them as if they were moments
with only a main part, and update other built-in Scheme and C++ code as
necessary. Some user Scheme code might need to be updated manually if
these things are not enough to keep it working when it reads a number
instead of a moment. I'm not very enthusiastic about skipping straight
to this; I don't like to cause trouble.
Do you have any other ideas?
Regards,
--
Dan