develooper Front page | perl.perl5.porters | Postings from May 2013

Re: Proposal: initial type annotation in SV

Thread Previous | Thread Next
Dave Mitchell
May 6, 2013 10:02
Re: Proposal: initial type annotation in SV
Message ID:
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>) {
	my ($x,$y) = split / /, $_;
	my $z = sqrt($x*$x + $y*$y);
	... serialise $x, $y, $z;
    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

Also I think you'll be hard pushed to find any spare bits in sv_flags to
record this info.

"I do not resent criticism, even when, for the sake of emphasis,
it parts for the time with reality".
    -- Winston Churchill, House of Commons, 22nd Jan 1941.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About