On 11/02/2014 05:34 PM, Henrik Lindberg wrote:
> On 2014-02-11 10:19, Joshua Hoblitt wrote:
>> On 11/01/2014 03:35 AM, David Schmitt wrote:
>>> On 2014-11-01 01:22, Henrik Lindberg wrote:
>>>
>>> The requirement to compare strings and numerals can also be
>>> implemented by converting the numeral to a string (using a canoical
>>> non-locale dependent format). This produces a much safer route, as
>>> creating a string has less degrees of freedom.
>> I believe this is the perl5 approach, which seems to be robust.
> 
> One has to remember that Number to String also has a number of options -
> which radix/base to use, the number of significant digits, scientific
> notation for floating point etc.

All the languages that I'm aware of, if they do implicit conversion S
<-> I conversion, it's in base 10.

This is hex conversion in Ruby.  It seems even if your explicit about
the conversion being hex you have to worry about case.

2.0.0-p353 :001 > "0F" == 15
 => false
2.0.0-p353 :002 > "0f".to_i(16) == 15
 => true
2.0.0-p353 :003 > "0F" == 15.to_s(16)
 => false
2.0.0-p353 :004 > "F" == 15.to_s(16)
 => false
2.0.0-p353 :005 > "f" == 15.to_s(16)
 => true
2.0.0-p353 :006 > "0F".to_i == 15
 => false
2.0.0-p353 :007 > "0F".to_i(16) == 15
 => true

That may be an argument for all conversions having to be explicit but
I'm fearful of the breakage that would cause for existing manifests,
assuming this wouldn't be an 'opt-in' behavior.

-Josh

--

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/5457ECD9.4060705%40cpan.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to