in reply to Re: list reversal closure
in thread list reversal closure

While I agree with the thesis that appears to be implicit in your post (that only real-world problem solving can provide a truly comprehensive measure of a language's benefits), that's not terribly useful for discussion with "hard" data on hand. As such, I've gone a little closer to the scientific method approach by trying to work with a series of clearly defined, strictly regulated mini-tests that each focus on specific characteristics of languages while minimizing the problem of additional, unnecessary variables. As such, for this particular test, I'm looking for fewer untargeted variables in the test, not more of them.

This unfortunately tends to result in a test whose conditions appear somewhat arbitrary and extraneous, until one considers the fact that the conditions are sorta the point.

If, however, you think another approach than using @ARGV would be better, I certainly encourage you to modify my code (or write code from scratch) to improve upon my original, and if you have suggestions for addressing the needs of this little test directly as opposed to attempting to turn it into a real-world problem, I'm open to that as well.

print substr("Just another Perl hacker", 0, -2);
- apotheon
CopyWrite Chad Perrin

Replies are listed 'Best First'.
Re^3: list reversal closure
by xdg (Monsignor) on Aug 21, 2006 at 13:32 UTC

    Put more simply, most languages assume the existence of command line arguments in an array, which eliminates the overhead of using the language or system libraries to process input for the test.

    That does treat some languages more fairly, but it's not really reflective of any real world condition. You might as well begin by having the language explicitly set an array or variable with a specified input.

    Side note on the closures bit -- a better, practical closures example is probably some sort of argument currying.

    sub first_n_chars { my $n = shift; return sub { return substr( shift, 0, $n ) }; } my $first_4 = first_n_chars(4); print $first_4->("hello world");

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      You make some excellent points, and you're right about an argument currying example being perhaps more practical. On the other hand, if I start chasing practicality, I then end up wanting to input data to the closure (both as the closure variable and when calling it) from "somewhere else", which begins to increase the complexity of the example to the point where it distracts from the core intent of the test.

      Maybe I just have a personal problem with setting arbitrary limits rather than following decisions to their logical extremes in a case like this.

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin