in reply to Re^2: Using closures to achieve data hiding in OO Perl
in thread Using closures to achieve data hiding in OO Perl
I didn't say closures were hard to debug, and I don't think that's true in most cases.
What's difficult to debug are objects that hide their attributes. You can't dump them (fixable) or inspect them in a debugger (not fixable).
In C, private attributes are hidden by denying code access to them. The debugger isn't subject to those access restrictions, so it can access private attributes just as easily as public ones. In Perl, the attributes aren't simply hidden. They are fundamentally different than public attributes. In a sense, they're not even in the object. (In inside-out objects, they truly aren't in the object at all.)
So what has no cost in C has a great cost in Perl.
How often do you guys use closures?
Often (but never for the purpose you propose). I worked on a VB project recently, and closures were what I missed the most.
|
---|