Perhaps I'm just having trouble following the thread, but I see MMD the other way around. MMD's job is to make it easy to have subroutines which are concrete and unambiguous.

=item calculate_area The calculate_area function calculates the area of the points passed in. You can pass the points in a number of different ways, but, regardless, you'll get the area back. =over 4 =item * You can pass in a series of points. The function will assume that the shape described is a closed-shape, that is, the first point is automatically repeated as the end point. You can pass in the points as perl6 pairs, e.g.: $area = calculate_area( $x0 => $y0, $x1 => $y1 ); or as two lists of x's and y's: $area = calculate_area( @x, @y ); or as a list of Point objects $area = calculate_area( @points ); =item * You can pass in a Shape object. $area = calculate_area( $shape ); =item * You can pass in an equation, and a beginning x-value and an ending x-value, and the area will be that under the curve. The area may be negative in this case. $area = calculate_area( $equation, $x0, $x1 ); =back Returns: the area of the shape, in square units. =cut
To me, the subroutine is incredibly unambiguous. It calculates area. It's a nice DWIMmy function that can handle any type of input. However, if I were to maintain this type of DWIMmery, it'd be a minor headache - I'd resort to something like this:
sub calculate_area { unless ( grep { ref $_ ne 'Pair' } @_ ) { goto \&_calculate_area_pairs; } if (@_ % 2 == 0 and not ref $_[0]) { goto \&_calculate_area_x_list_y_list; } unless ( grep { ref $_ ne 'Point' } @_ ) { goto \&_calculate_area_list_of_points; } unless ( grep { ref $_ ne 'ARRAY' } @_ ) { goto \&_calculate_area_list_of_arrays; } if (UNIVERSAL::isa($_[0], 'Shape')) { goto \&_calculate_area_share; } if (UNIVERSAL::isa($_[0], 'Equation') and @_ == 3) { goto \&_calculate_area_equation; } die "Didn't recognise how you called calculate_area"; }
And then I'd implement each possibility in a separate function. The interface is simple, and very perlish (DWIM's very well - and can add more DWIMmery later). The code is ugly. MMD handles the ugly part of the code in a very generic manner which means that it only needs to be debugged by the p6 team, not by each developer who wants it. Because I'm quite sure I've got sneaky little bugs in that untested code above.


In reply to Re^6: The beauty of MMD by Tanktalus
in thread Perl 5's greatest limitation is...? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.