develooper Front page | perl.perl5.porters | Postings from August 2013

Idea: ARRAY ARROW implies MAP

Thread Next
From:
David Nicol
Date:
August 16, 2013 20:38
Subject:
Idea: ARRAY ARROW implies MAP
Message ID:
CAFwScO9NH3JhKs+0hULCD=-PvXGGw5znxFGgA2_dsJ+Q3BV00A@mail.gmail.com
Would it be cool if

@array->bar(27)

became, essentially,

( map { $_->bar(27) } @array )

and if

@array->[27]

became, essentially,

( map { $_->[27] } @array )


and if

@array->{ts}

became, essentially,

( map { $_->{ts} } @array )

?
That is, if, in general,

@array->more->things

became, essentially,

( map { $_->more->things } @array )

?

This would mean that a @LoLoL, currently fully flattenable with

@Fluffy = map { @$_ } map {@$_} @LoLoL;

might become flattenable with

@Fluffy = @@@LoLoL;

or maybe it would only work with the new postfix syntax,

@Fluffy = @LoLoL->@*->@*;


I imagine that some would find that useful and elegant, and others would
find it over-concise and confusing and think it an invitation to error as
misspellings get mis-parsed as expansions.

Thoughts?

dln

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