On 2020-06-10 10:28 am, Paolo Prete wrote:
... I have been misled by the term "rational". In fact, in the italian
language the term "rational" (---> razionale) means an irreducible
fraction of two coprime integers, while in the english language it
means a
number that can be expressed as the quotient or fraction p/q of two
integers.
For example, "2/4" is not rational in italian, but it is rational in
english. Then I did not even consider that predicate.
I suggest the italian maintainer of the translation to keep note of
this
ambiguity.
I would not be so hasty.
A rational value and a fraction are two related but distinct things. A
fraction is the thing that consists of a numerator and a denominator,
whereas the rational value is the ratio between the two components of
the fraction. So to say "2/4 is rational in English" is potentially
misleading. Regardless of native tongue, 2/4 is specifically a fraction
that simply has a rational value of 1:2. 2/4 is not the rational value,
1:2 is. 2/4 may be reduced to 1/2 which shares the same ratio, so we
would say we have two fractions but only one rational value.
Connecting the above to Scheme, fraction? and rational? are distinct
type predicates. A fraction? is simply a pair of numbers--the car
holding the numerator, the cdr holding the denominator. On the other
hand, a rational? refers to one of the primitive numeric types. Of most
importance, a rational? will be reduced whereas a fraction? will
preserve the original numerator and denominator.
Going back to the original question regarding fractions, my suggested
use of rational? would *not* be useful if you need to preserve the
original numerator and denominator. Otherwise, things like 4/4 and 2/2
would look identical to the function. In fact, the function would
simply see the integer 1 as input for #4/4. If all that was needed was
to specify a duration, then it might not matter since four quarters is
the same as two halves. However then, David's suggestion of using
ly:duration? would make much more sense.
-- Aaron Hill