Hi Michael,

> Perl has no real object oriented features today. So it is not possible
> to declare private and public functions within the server.

first, it is common practice to begin functions that are meant to
be private with an underscore. A caller could, of course, call such
a function, but it is widely known among Perl hackers that this
is Not Good.

Solution 1:
package foo;

sub _private {
...
}


But private functions can also be implemented this way (without
any performance impact):

package foo;
my $private = sub {
...
};

sub public {
  $private->();
}


Or even:

package foo;

sub new {
  my $proto = shift;
  my $class = ref($proto) || $proto;

  my $self = {};
  bless $self, $class;

  # Private methods
  $self->{PRIVATE}->{bar} =
    sub {
       ...
    };

}

...
$self->{PRIVATE}->{bar}->(arg...);


Just some ideas.

I do not like delegation of methods to other classes just to emulate
this feature.

Martin



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
OpenCA-Devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/openca-devel

Reply via email to