Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1416)

Issue 573570043: Issue 5790: Rational conversion clean-up (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
4 years, 2 months ago by Dan Eble
Modified:
4 years, 2 months ago
Reviewers:
dak, lemzwerg, hanwenn
CC:
lilypond-devel_gnu.org
Visibility:
Public.

Description

https://sourceforge.net/p/testlilyissues/issues/5790/ This review squashes these commits that mainly clean up initialization and conversion of Rationals, though there are some minor bug fixes. For most of the unit tests which are disabled here, I have fixes that I am holding back for the sake of simplifying this review. 1: create unit tests 2: remove unused infinity_rat 3: use default copy-construction and assignment 4: disambiguate integer conversions and fix sign when initialized by unsigned integer 5: disable implicit conversion to bool 6: discard r.to_double () in favor of static_cast<double> (r) This helps developers avoid question-raising statements like this: Real x = r.to_double (); and encourages statements like this: auto x = static_cast<Real> (r); 7: disable implicit conversion to double This helps emphasize places where exactness might be lost. 8: to_int () becomes trunc_int () and returns I64 like num () and den ().

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+234 lines, -50 lines) Patch
M flower/include/rational.hh View 3 chunks +17 lines, -25 lines 0 comments Download
M flower/rational.cc View 4 chunks +11 lines, -18 lines 0 comments Download
A flower/test-rational.cc View 1 chunk +197 lines, -0 lines 0 comments Download
M lily/audio-item.cc View 1 chunk +1 line, -1 line 0 comments Download
M lily/grace-iterator.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M lily/multi-measure-rest.cc View 1 chunk +1 line, -1 line 0 comments Download
M lily/spacing-basic.cc View 1 chunk +2 lines, -1 line 0 comments Download
M lily/spacing-options.cc View 1 chunk +1 line, -1 line 0 comments Download
M lily/tempo-performer.cc View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 3
lemzwerg
Very nice, thanks! LGTM.
4 years, 2 months ago (2020-02-25 05:54:18 UTC) #1
hanwenn
LGTM (I wonder if we should bite the bullet and use uint64_t iso. U64.)
4 years, 2 months ago (2020-02-25 08:07:14 UTC) #2
dak
4 years, 2 months ago (2020-02-25 10:35:56 UTC) #3
On 2020/02/25 08:07:14, hanwenn wrote:
> LGTM
> 
> (I wonder if we should bite the bullet and use uint64_t iso. U64.)

Just for the record: the big bullet would be a Simple_smob wrapper class around
Guile's rational data type.  Showstopper in the current setup: Moments in data
structures contain rationals and would need to get heap-marked, but the Midi
data structures are not memory-managed by Scheme.  Even the non-showstopper
parts would be quite a bit of work.  Workaround/migration strategy could be a
variant adding itself into a doubly-linked list of data structures to be marked
outside of the normal Scheme mechanisms and handled by construction/destruction
and reference counting, with the obvious memory overhead.

The alternative would be to base our implementation of rationals not on U64 but
on GNU mp.  There is


 -- C Function: void scm_to_mpz (SCM val, mpz_t rop)
     Assign VAL to the multiple precision integer ROP.  VAL must be an
     exact integer, otherwise an error will be signalled.  ROP must have
     been initialized with ‘mpz_init’ before this function is called.
     When ROP is no longer needed the occupied space must be freed with
     ‘mpz_clear’.  *Note (gmp)Initializing Integers::, for details.

 -- C Function: SCM scm_from_mpz (mpz_t val)
     Return the ‘SCM’ value that represents VAL.

but that sounds like slowing down things more.  Maybe we should collect this
JFTR in some actual issue.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b