Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Array iterator factory

by tlm (Prior)
on Mar 16, 2005 at 18:54 UTC ( #440091=note: print w/ replies, xml ) Need Help??


in reply to Array iterator factory

Just a minor point: using a (\@) prototype in the definition of array_iterator, as opposed to just using @_, rules out uses like array_iterator(1..10). Is there a particular benefit of using a prototype here that you are after?

the lowliest monk


Comment on Re: Array iterator factory
Select or Download Code
Re^2: Array iterator factory
by Roy Johnson (Monsignor) on Mar 16, 2005 at 19:30 UTC
    If I took a list, I'd have to make and store a copy of its contents. It would be expensive, and it would not see subsequent changes to the original array. I wanted a lightweight iterator tied to a user-modifiable array.

    The user can create an anonymous array and slap an iterator on it, if he so desires: array_iterator(@{[1..10]}). That makes it obvious that this iterator can't give you the free lunch that for (1..10) does.


    Caution: Contents may have been coded under pressure.

      Don't forget the power of &array_iterator([1..10]).

      - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://440091]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-07-01 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls