*thinks for a moment*
*springs up and shouts* Perl does do that!
Here's a standard constructor in Perl:
My point here is that, since Perl doesn't have a mechanism to (natively) define a class in a series of declarative statements (like C++, for example), the "class declaration" is done during new().sub new { my $class = shift; my %args = @_; my $self = bless {}, $class; $self->{attrib1} = $args{attrib1} || 'Default 1'; $self->{attrib2} = $args{attrib1} || 'Default 2'; return $self; }
Now, you can do other stuff. I have my own personal virtual base class that gives me the capability to "declare" a class at compile time, with default values. I could post it, if desired. *shrugs* It's not that hard!
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
In reply to Re: OOP,
by dragonchild
in thread OOP, ".NET", Perl, and all that
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |