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

Re: [PATCH] Remove implicit split to @_

Thread Previous | Thread Next
From:
Ben Morrow
Date:
July 9, 2009 18:23
Subject:
Re: [PATCH] Remove implicit split to @_
Message ID:
20090710012301.GA7079@osiris.mauzo.dyndns.org
Quoth sthoenna@efn.org (Yitzchak Scott-Thoennes):
> 
> I was trying to give the IMO underappreciated y/// some love.  It's hard
> to say for sure what I'd really do, since I find it hard to imagine
> counting fields without actually wanting the fields:
> 
> @fields = split ...;
> $field_count = @fields;
> 
> but if it actually came up in practice, I might just:
> 
> $field_count = () = split ...;
> 
> I'm not completely satisfied that "fixing" scalar context is the right
> thing to do; just like with sort, where there are several "right" scalar
> context behaviors.
> 
> With my C hat on, I'd expect it to return the first field, like strtok.
> Without it, I'd be as inclined to expect the last field as to expect
> a count.

So: fatal error (at compile-time where possible), rather than a warning
and weird behaviour?

If it's not an error, I'd expect a count. map and grep both return a
count, and scalar split already returns a count.

+1 to getting it fixed somehow, anyway.

Ben


Thread Previous | Thread Next


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