On Wed, Jun 8, 2022 at 3:24 PM Marco van de Voort via fpc-devel <fpc-devel@lists.freepascal.org> wrote:
> I doubt that there are mission critical convutils programs out there, > given the fact that it took 10+ years to find out the temperature > conversion didn't work :-) I agree. I only stubled upon this unit because I have unit that converses integers to string in a base (up to base 36) and I wondered if fpc had a general conversion unit, where perhaps it could be added. That's how I found the StdConvs unit and then discovered the temperature bug. The rest is, as they say, history. > Usage is low, risk is small, I say, go ahead. This still leaves us with the returnvalue of ConvTypeToFamily, which should indicate if an has occurred. However, at least in D7, ConvTypeToFamily does NOT return 0 if an error occurs, but it raises an exception. So, what to do for that one: follow the docs, or follow the observed behavoir of D7 (again, someone should test a newer version)? Basically since both TConvFamily and TConvType are of type Word (in Delphi), it is impossible to return a number that indicates an error at all (unless you fill both Families[0] and RegisteredConvTypes[0] with info indicating they are invalid (which D7 seems not to do). Which makes the CIllegalConvFamily and CIllegalConvType constants rather useless. The only function that actually returns a TConvType (AFAICS) raises an exception upon error. So, we can go 2 ways: 1. Leave TConvFamily and TConvType and change CIllegalConvFamily to -1 Not Delphi compatible 2. Make TConvFamily and TConvType of type Word, raise an exception in ConvTypeToFamily upon error. This needs some refactoring to limit the amount of TConvTypes that can be registered. It's not compliant with the Delphi docs. I would tend to also implement TryXXX functions for all procs/functions that will raise conversion exceptions in that case. Just to be consistent with most of our conversion routines we have. Then there is the issue with ConvFamilyToDescription: should it return an empty string if the family does not exist (current behaviour) or "Illegal family", as D7 does? I would leave it as it is, since "illegal family" is a legal name for a family to register... @Marco: I first need to have the patches in #39774 and #39773 applied before embarking on this. -- Bart _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel