YAML's No in Perl
dgaramond2
created: 2006-03-13 05:24:30
Sigh, I've been bitten by this at least 3-4 times. First a couple of years ago with some version of YAML. And then with some version of YAML::Parser::Syck. And just now with YAML::Syck. I'm using Perl, Ruby, PHP, and to a much less extent Python. Strangely, all of them but Perl have had no problem with No being false, but interestingly in Perl we are confused every now and then and load No as the string 'No'. What's going on here? :-)
Re: YAML's No in Perl
created: 2006-03-13 07:06:06
Strangely, all of them but Perl have had no problem with No being false, but interestingly in Perl we are confused every now and then and load No as the string 'No'. What's going on here? :-)

Bugs from the sound of it. I'm sure the developers would love a nicely wrapped up test case and an RT bug report :-)

Re: YAML's No in Perl
created: 2006-03-13 07:11:13
Perl evaluates 0, undef and '' (empty string) as false in scalar context. It evaluates () (empty list) as false in list context. Any other string evaluates as true. I don't see what's wrong with that; if "No" evaluates false, what about "NO", "no", "N" ? What about "Non", "Niet", "Nein" and "La'" ?
Re^2: YAML's No in Perl
created: 2006-03-13 07:22:03
I don't see what's wrong with that; if "No" evaluates false, what about "NO", "no", "N" ? What about "Non", "Niet", "Nein" and "La'" ?

In YAML it can be a representation of a boolean value - see Boolean Language-Independent Type for YAML™ Version 1.1 for details. So it can make sense for a YAML parser to translate this to a false value in Perl land.

Re^3: YAML's No in Perl
created: 2006-03-13 11:17:29
I see. It could be then a nice feature to add to the YAML module. After all, it's only an alpha release : latest is 0.58.
Re^4: YAML's No in Perl
created: 2006-03-13 14:12:07

CPAN version numbers and their relationship to "1" have nothing to do with alpha status. A few authors adopt the <1==alpha|beta meaning but not most of them.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: YAML's No in Perl
created: 2006-03-13 14:12:09
use YAML::Syck;
$YAML::Syck::ImplicitTyping = 1;
Load("No"); # undef
I had ImplicitTyping on, but Ingy told me it should be off by default to save time and reduce confusion and improve compatibility. So... Blame him. :-)
Re^2: YAML's No in Perl
created: 2006-03-13 20:27:05

Hi audrey.

Save time? Execution time? Please explain... I think YAML::Syck is fast enough for all of my needs.

Improve compatibility with what, older Perl modules (all of which are 'alpha' or 'beta' and should not guarantee API/backwards compatibility anyway)? I would vote for better interoperability with the other YAML-using languages, as it is one of YAML's biggest strength.

Reduce confusion? Hm, that's not what I experienced. Implicit typing is also one of YAML's basic features.

So, turn it and keep it on please :)

Re^3: YAML's No in Perl
created: 2006-03-14 07:45:50
Okay, I did add a prominient notice to YAML::Syck 0.38 and credited you for it in the ChangeLog. Thanks!
Re^4: YAML's No in Perl
created: 2006-03-14 22:02:12
Sweet, thanks! I'm ready to be blamed for this in the future :-)
Re^2: YAML's No in Perl
bsb
created: 2006-07-23 19:49:26
I think Ingy's right, implicit typing should be off by default. It caused all kinds of bugs including turning an md5 hash string that happened to match /^\d+e\d+$/ into NaN.

Implicit typing should only be enabled if it doesn't interfere with round-tripping, Perl's polymorphic scalars seem to me to make this impossible.

ImplicitTyping--

perlmonks.org content © perlmonks.org and adrianh, audreyt, bsb, dgaramond2, diotalevi, wazoox

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03