Hmm, I'm hard-pressed to argue that point. If I were to come up with something else, I would argue that the lack of multi-method dispatch is a pretty big problem. Of course, that's sort of cheating because if you get that, it automatically implies proper argument handling and I therefore get two for the price of one :)
Unfortunately, I've seen those who have not had a chance to work extensively with MMD aren't terribly impressed by its benefits. My suggestion to them would be to take a program written in a language which supports this and try to port it to Perl. It leads to monstrosities like the constructor for AI::Prolog::Term:
sub new {
my $proto = shift;
my $class = CORE::ref $proto || $proto; # yes, I know what I'm doi
+ng
return $class->_new_var unless @_;
if (2 == @_) { # more common (performance)
return _new_from_functor_and_arity($class, @_) unless 'ARRAY'
+eq CORE::ref $_[1];
}
elsif (1 == @_) {
my $arg = shift;
return _new_with_id($class, $arg) if ! CORE::ref $arg && $
+arg =~ /^[[:digit:]]+$/;
return _new_from_string($class, $arg) if ! CORE::ref $arg;
return $arg->_term($class) if CORE::ref $arg && $
+arg->isa(Parser);
}
require Carp;
Carp::croak("Unknown arguments to Term->new");
}
That constructor was buggy for a long time because Perl doesn't support MMD. It was very frustrating.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|