in reply to characterstics of private in perl

As we all know Perl can do anything! See this.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: characterstics of private in perl
by Cabrion (Friar) on Mar 09, 2003 at 12:17 UTC
    Just because you can doesn't make it a good idea. I have no doubt Larry et. al. put a great deal of thought into giving Perl the magic power of private memebers in a more straight forward manner. The fact that they chose not to, and the fact that they are far smarter than I, tells me there is a reason to not write contorted privacy code in the general case. I think that's what the OP was asking.

    he, he . . I said member.

      Just because you cannot do something doesn't mean it's a bad idea :-) Did the fact that perl4 didn't have lexical variables or OO mean they were a bad ideas?

      There are good reasons for proper encapsulation. The only reason "privacy" code is contorted in perl5 is because perl5 doesn't provide the necessary functionality. Writing OO code in perl4 was "contorted" too ;-).

      You can do private methods and object attributes in various evil hacky ways in perl5. Sometimes this is necessary. Fortunately perl is an evolving language and, from what I understand, you will be able to do it nicely in perl6.