Dave Mitchell wrote: > On Sun, May 05, 2013 at 11:45:25PM +0200, Sébastien Aperghis-Tramoni wrote: > > So, here is a proposal to try making this situation a bit better: > > annotate the SV to record the initial (or canonical) type of the the > > value, that is the type of the value that was last affected to the SV. > > But I don't think that necessarily solves the problem. Consider: > > while (<DATA>) { > chomp; > my ($x,$y) = split / /, $_; > my $z = sqrt($x*$x + $y*$y); > ... serialise $x, $y, $z; > } > __DATA__ > 0.123 1.234 > ... > > should $x, $y be serialised as strings or floats? I think the desire of > the programmer would be for them to be floats, but the canonical form is > string. In other words, the initial type still doesn't necessarily DWIM, > and its still up to the programmer to manually ensure the output is as > desired. split() returns strings, so $x and $y should be annotated as strings, and therefore serialized as strings. Note that I do not expect to magically fix things, that's be unreasonable, and would certainly break things. I mostly want to annotate the SV enough so modules like serializers have hints to behave correctly. > Also I think you'll be hard pushed to find any spare bits in sv_flags to > record this info. Yes, as I discovered through quick experiments, I was a bit too optimistic. But this wasn't a surprise, because I guess that if it had been that simple, it would have been implemented years ago. -- Sébastien Aperghis-Tramoni Close the world, txEn eht nepO.Thread Previous | Thread Next