develooper Front page | perl.perl5.porters | Postings from June 2019

Re: Making join() respect string-concat operator

Thread Previous
From:
Dave Mitchell
Date:
June 12, 2019 09:32
Subject:
Re: Making join() respect string-concat operator
Message ID:
20190612093215.GO4761@iabyn.com
On Tue, Jun 11, 2019 at 10:29:28AM -0400, Matthew Horsfall (alh) wrote:
> Sorry, my example had one too few arguments:
> 
> alh@hyrule:~$ perl
>    use overload
>         '""' => sub { print "STRFY($_[0][0])\n"; $_[0][0] },
>         '.'  => sub { print "CONCAT$_[0][0], $_[1][0])\n";
>                         bless [ $_[0][0] . $_[1][0] ] }
>         ;
> 
>     my $s = bless [ "foo" ];
>     my $t = "$s $s";
> CONCATfoo, )
> CONCATfoo, foo)

Yeah, but double-quotish string interpolation is well understood(*) to
be just syntactic sugar for string concatenation, and indeed compiles to
OP_CONCAT ops.

(*) for some definition of "well".

-- 
Music lesson: a symbiotic relationship whereby a pupil's embellishments
concerning the amount of practice performed since the last lesson are
rewarded with embellishments from the teacher concerning the pupil's
progress over the corresponding period.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About