Suggestions:
- Instead of storing
KdlValue::Float as f64, store it as String
- Instead of storing
KdlValue::Integer as i128, store it as { repr: String, radix: u32 } where the radix can only be 2, 8, 10 or 16
This should make the library both simpler implementation-wise, but also more versatile
Since kdl parser can be used for any purpose, it should be up to the user of the crate to decide how to parse the values
This would improve performance because it would remove an unnecessary step in certain situations: The KDL library converts the int/float to a string, but then we have to .to_string() it back.
There is no logical distinction in KDL between real numbers, integers, and floating point numbers. It's up to individual implementations to determine how to represent KDL numbers.
from the spec
Given the above, i should be able to represent an i1024 or f512 in KDL by using the kdl crate - or any sort of number, but this is currently impossible
One difficulty with this approach is: What do we do about #inf, #-inf and #nan?. Personally, I think they could be represented by adding 2 new variants to KdlValue - KdlValue::Inf { is_positive: bool } and KdlValue::NaN.
Suggestions:
KdlValue::Floatasf64, store it asStringKdlValue::Integerasi128, store it as{ repr: String, radix: u32 }where the radix can only be2,8,10or16This should make the library both simpler implementation-wise, but also more versatile
Since
kdlparser can be used for any purpose, it should be up to the user of the crate to decide how to parse the valuesThis would improve performance because it would remove an unnecessary step in certain situations: The KDL library converts the int/float to a string, but then we have to
.to_string()it back.Given the above, i should be able to represent an
i1024orf512in KDL by using thekdlcrate - or any sort of number, but this is currently impossibleOne difficulty with this approach is: What do we do about
#inf,#-infand#nan?. Personally, I think they could be represented by adding 2 new variants toKdlValue-KdlValue::Inf { is_positive: bool }andKdlValue::NaN.