Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Index or iterate - your choice

by bliako (Monsignor)
on Jan 27, 2021 at 10:18 UTC ( [id://11127514]=note: print w/replies, xml ) Need Help??


in reply to Index or iterate - your choice

I am not acquainted with the ELF and what functionality a potential user may desire from your module. So I will risk some general points.

Filtering (the ELF segments) can be important and could even expand to checks other than size>0. In both get() methods you do this filtering by hand, inside the loop. If indeed there is scope for filtering useless segments and selecting "interesting" (hmmmm!!) segments then I would re-pose the problem. It looks to me that such a functionality would be very appealing. But is the array or the iterator suited for this best? Usually when filtering, one expects the result collection to be of the same type as the input, e.g. an array or iterator (Edit: and even offer in-place editing). Neither looks suitable though for filtering! Splicing an array? Linkedlist?

There is also the question of passing the segments, array or iterator, to another sub/module for further processing, filtering, profiling etc. I would think an arrayref is the least common denominator here. Unless that other module is yours and you control the API.

But there is also the problem of creating new iterators to return back after filtering and selecting. Possibly pipelined. Would (not-)garbage-collecting the iterators be a problem?

As I said I am ignorant about ELF, but perhaps it makes sense to store the segments in a linkedlist/graph/tree? Perhaps for adding/removing a new segment and then writing out the ELF?

Replies are listed 'Best First'.
Re^2: Index or iterate - your choice
by GrandFather (Saint) on Jan 27, 2021 at 21:46 UTC

    Nice! I hadn't thought of filtering returned results. To me the iterator feels like a pretty natural way to do that. As it stands the module is a reader so the semantics for the collection is read only. However changing the module to an ELF manager is an attractive thought. It impinges on ELF::Writer's solution space, but the APIs for my module and NERDVANA's module are quite different so maybe creating a "one size fits all" module makes sense?

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-19 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found