Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^6: reduce like iterators

by tilly (Archbishop)
on Jan 19, 2011 at 01:14 UTC ( [id://883029]=note: print w/replies, xml ) Need Help??


in reply to Re^5: reduce like iterators
in thread reduce like iterators

In general and in theory, no.

But lots of people have so done, and it works out reasonably well in practice. For a random example Dominus used char(20) for this purpose in the widely used Memoize. (Then documented the limitation.) This code is significantly faster than a robust escape mechanism would have been, and he provided a mechanism to fix the potential bug if you needed to.

Replies are listed 'Best First'.
Re^7: reduce like iterators
by LanX (Saint) on Jan 19, 2011 at 12:53 UTC
    I know and agree that the probability of a bug is much smaller when using a magic string, and at the end "bug-freeness" of non-trivial code is only a product of probabilities.

    In other words IT isn't math!

    But I prefer solutions where I don't have to document (and keep in mind) rare side cases.

    Especially in this case, simulating reduce's approach to start with the first two values is clean and elegant.

    Cheers Rolf

Log In?
Username:
Password:

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

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

    No recent polls found