Replies: 6 comments 4 replies
-
Objects felt a bit too heavyweight for this. The approach would be something like Is there a specific problem you've encountered with the array approach? |
Beta Was this translation helpful? Give feedback.
-
No, no problem. I just think it is a potential source of errors. I am just getting around to testing if the schema enforces exactly 2 array elements. (If it doesn't that's a source of errors.) Interpreting which is num and which is den is another potential source of errors. Can the schema throw an error if f[1] == 0? Because that's an illegal value. I'm just thinking the schema might be able prevent these kinds of errors easier if it were an object. |
Beta Was this translation helpful? Give feedback.
-
As a followup: I just tried creating a fraction with 3 elements and it validated against the schema without error. This strikes me as a significant weakness of using an array for the fraction object. |
Beta Was this translation helpful? Give feedback.
-
I think it's far-fetched to think someone will see [3, 4] and be confused about whether this means 3/4 or 4/3. If we're looking for music representation precedents for storing fractions this way, it's all over the Vexflow code. |
Beta Was this translation helpful? Give feedback.
-
It's just semantically incorrect to treat a time signature as a fraction. 4/4 and 2/2 have different meanings, but evaluate to the same number when treated as fractions. Time signatures are not fractions, even though they bear some resemblance. |
Beta Was this translation helpful? Give feedback.
-
It is quite easy to imagine that a program bug might cause them to be written backwards. How a human would interpret them seems irrelevant. Once they are used for real, many files will have no indentation, and these will be opaque to humans. The goal here is early failure, which means schema validation should catch as many errors as possible. I'm cool with the tuplet validation described above. Then the only thing being given up is named access for each field. It seems as though the array can be validated
That seems like a reasonable tradeoff. |
Beta Was this translation helpful? Give feedback.
-
I am a little puzzled why fractions are defined as arrays and not objects. Enforcing an array of exactly 2 elements seems like what objects are designed for.
Beta Was this translation helpful? Give feedback.
All reactions