develooper Front page | perl.perl5.porters | Postings from July 2000

proposed extension to join

July 30, 2000 14:55
proposed extension to join
Message ID:
When I first saw Wolfgang's proposal, I thought perhaps you could do
it this way:

[D:\home\sthoenna]perl5.6.0 -wl
{ package CircQueue; use overload '""'=>'Next';
  sub new { my ($class, @q) = @_; bless \@q, $class }
  sub Next { my $q = shift; push @$q, my $val = shift @$q; $val }
$x = CircQueue::->new(1,2,3);
print join $x, 'a'..'e';

But, as you can see, that doesn't get you 'a1b2c3d1e' as desired.

Does anyone have feelings about making join work this way (that is to
say, getting the delim multiple times if it has magic?)  This wouldn't
affect the performance with a non-magical delimiter much at all.

For the initial check of whether to grow the target (doop.c line 486 @
6415), I would just use the initial length of the delimeter, since
this seems to be just a rough test of whether the target has been used

Any opinions on whether (without regard to performance) join 'should'
work one way or the other?  And whether the performance hit for
delims with magic is worth it? Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About