Closed nmathewson closed 5 months ago
Hi. I'm one of @nmathewson's colleagues. I mostly just wanted to say thanks to @SergioBenitez for engaging with this, to try to help meet our needs. @nmathewson, I'd be happy to help here. Eg, would you like me to read the code in this MR?
I did have one question. Why are we calling these methods "lossy"? I hope they aren't really lossy. But I just came in here so maybe I am confused...
I really like this idea, and I'm committed to reviewing/merging this as soon as I free up a bit (in the next few days)!
@ijackson Thank you! I chose "lossy" because we lose the true type information in the conversion process. In this comment I show how this is truly a loss and not just a conversion.
@ijackson Thank you! I chose "lossy" because we lose the true type information in the conversion process. In https://github.com/SergioBenitez/Figment/pull/97#issuecomment-2030957484 I show how this is truly a loss and not just a conversion.
I do agree that when we consider these conversions as applied to individual strings or numbers, they are lossy: When you convert "yes"
to true
, you can't recover the original "yes"
if it turns out that what you really wanted was a string.
But I wonder whether "lossy" is the right word for the overall feature when applied to an entire configuration in extract_lossy
. When we convert "yes"
to true
in the context of a boolean option, we aren't losing any information, any more than you we are when we treat 1.0
and 1.00
as the same float.
(Edited to add: That said, having this option is more important to me than having the perfect name for this option. :) )
Published in 0.10.18! Thanks for working with me on this. Fantastic work!
This is a second attempt to implement the idea of #97.
Instead of changing the default behavior of
impl Deserialize for *
, it instead provides newextract_lossy
andextract_inner_lossy
methods that implement the lossy behavior across the entire figment object.(As an alternative, as discussed on #97, the user might annotate all their booleans and numbers with
deserialize_with
. But it can be error-prone to do so, especially if the configuration structure is large and complex.)