in reply to Re: Array copy or encapsulation break?
in thread Array copy or encapsulation break?

If the list is a hash, you could tie that hash to your your package and give the caller the tied handle. That way, they can manipulate the hash with all the familiar hash operators (keys, values, each etc. and the standard method of resetting these iterators), but you get to intervene in every operation and vet what they do.

Using ties this way makes for a nice perlish and familar standard interface to class attributes, including using them as lvalues, without relinguishing control. Ties aren't the fastest things in the world, but they're no slower than calling setters and getters.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.

  • Comment on Re: Re: Array copy or encapsulation break?