On 9/1/07, Ovid <[EMAIL PROTECTED]> wrote: > --- Eric Wilhelm <[EMAIL PROTECTED]> wrote: > > > I'm not sure the YAML spec distinguishes between string and number > > when > > the string is a number. > > > > $ perl -e 'use YAML; warn YAML::Dump([3,"3"]);' > > --- > > - 3 > > - 3 > > $ perl -e 'use YAML::Syck; warn YAML::Syck::Dump([3,"3"]);' > > --- > > - 3 > > - 3 > > Ah, crud. Is this because YAML doesn't quote things without whitespace? > That really seems like a serious limitation to me. Can I really keep > a straight face and tell a C programmer that the "Test Anything > Protocol" deliberately chose a serialization language that ignores data > types? > > This is mentioned in Wikipedia: > > http://en.wikipedia.org/wiki/YAML#Pitfalls_and_implementation_defects > > Workarounds for this issue are listed, but that still puts us in the > position of needing a pure-perl, core method of disambiguating > integers, floats, and strings.
No. I thought I already said this, but apparently not. There Is No Difference. The core doesn't track a difference except in the most trivial way. That you can tell a difference AT ALL is purely an implementation detail that hypothetically could change in some release of perl. Consider the following code: use Devel::Peek; my $x=3; my $y="3"; # $x and $y are different Dump $x; Dump $y; push @x, "".$x, 0+$y; # $x and $y are indistinguishable Dump $x; Dump $y; __END__ SV = IV(0x1a4beb0) at 0x1a458e0 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK) IV = 3 SV = PV(0x15d59dc) at 0x1a458f8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x15d96e4 "3"\0 CUR = 1 LEN = 2 SV = PVIV(0x15d5e0c) at 0x1a458e0 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,POK,pIOK,pPOK) IV = 3 PV = 0x1a744bc "3"\0 CUR = 1 LEN = 2 SV = PVIV(0x15d5e1c) at 0x1a458f8 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,POK,pIOK,pPOK) IV = 3 PV = 0x15d96e4 "3"\0 CUR = 1 LEN = 2 Notice that simply using a scalar in a numeric or string context will force it to upgrade to a form that holds both. And that is ignoring the issue of dual vars entirely. Id say forget this problem. If a tester wants this kind of detail he is going to output diagnostics that will deal with it, and its not your problem to worry about what they are. Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"