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

Re: Paren madness (was Re: Regex query)

From:
Jonathan Scott Duff
Date:
September 23, 2002 18:50
Subject:
Re: Paren madness (was Re: Regex query)
Message ID:
20020923205000.A2786@cbi.tamucc.edu
On Mon, Sep 23, 2002 at 04:58:55PM -0400, Trey Harris wrote:
>   for (1,("a","b","c"),3 { ... }
> 
> and
> 
>   for 1,("a","b","c"),3 { ... }
> 
> Now that I've ventured away from DWIMs and more into WIHDTEMs (What In
> Hell Does This Expression Mean), is the above equivalent to
> 
>   for 1,qw(a b c), 3 { ... }
> 
> as well?

I'd expect all 3 to mean exactly the same thing.

> A final unresolved question.  I take it that the splat operator is a
> deeply flattening operator.  For instance,
> 
>   *[1,[2,[3,4,5]],6]
> 
> will be converted into
> 
>   [1,2,3,4,5,6]

What other operator acts recursively in this fashion? None that I know
of.  If someone wants the recursive behavior, they can redefine the
operator appropriately.

Besides, with the ^ operator, you can already express arbitrary
levels:

	*[1,[2,[3,4,5]],6]		# 1,[2,[3,4,5]],6
	^*[1,[2,[3,4,5]],6]		# 1,2,[3,4,5],6
	^^*[1,[2,[3,4,5]],6]		# 1,2,3,4,5,6
	
et cetera.  :-)

-Scott
-- 
Jonathan Scott Duff
duff@cbi.tamucc.edu



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