develooper Front page | perl.perl6.language | Postings from September 2005

Re: Stringification, numification, and booleanification of pairs

Thread Previous | Thread Next
From:
Mark A. Biggar
Date:
September 25, 2005 19:42
Subject:
Re: Stringification, numification, and booleanification of pairs
In a private conversation with Larry this afternoon, he said that by 
default "$foo" and ~$foo and $foo.as(Str) all give the same result 
(assuming scalar context, etc.).  And that "@foo[]" and ~@foo and 
@foo.as(Str) are the same as join(' ', @foo) where join is effectively:

sub join(Str $x is rw, @A) {
     my Str $y = '';
     for $z -> (@A) {
	$y ~= ~$z;
     } continue {
	$y ~= $x:
     }
     return $y;
}

Also that a pair ($x => $y) stringifies to "$x\t$y" and that ~@A for an 
array of pairs is the same as join("\n", @A);

It is also intended that .as(Str, ...) takes extra named args (names 
TDB) for things like separators and sprintf like format strings so you 
can customize it, including ways to change the defaults for a class 
(like the separator for arrays of pairs being "\n" instead of ' ').

-- 
mark@biggar.org
mark.a.biggar@comcast.net

Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About