user-pic

mauke

  • About: I blog about Perl.
Subscribe to feed Recent Actions from mauke

  • Yuki Kimoto commented on I think subroutine signatures don't need arguments count checking

    Salvador Fandiño

    I didn't do benchmark.

    but logically run-time checking is one cost. string checking is not bad, but it is bad that the behavior is default.

    Perl is dynamic language, so default behavior should be dynamic one.

    For example, the following behavior is good.

    sub foo ($x, $y) {
    ...
    }
    # Same as
    sub foo {
    my ($x, $y) = @_;
    }

    sub foo ($x, $y) : strict {

    }
    # same as
    sub foo {
    die if @_ != 2;
    my ($x, $y) = @_;

  • Yuki Kimoto commented on I think subroutine signatures don't need arguments count checking

    >I think argument checks are a good thing because correctness is more important than speed (who cares how fast you are at getting the wrong result?).

    >Checking the arguments manually is annoying boilerplate code that no user wants to bother with. It's much better to be able to abstract it away and have the language do it for you automatically.

    Perl is dynamic language. Argument count checking should be optional. Logically run-time checking is one performance cost. In static language, arugument count checking can be done in compile-time, but in dynamic lanugage, it is done in …

  • Yuki Kimoto commented on I think subroutine signatures don't need arguments count checking

    I assume javascript function.

    function foo(x, y) {

    }

    foo(1) // ok
    foo(1, 2) // ok
    foo(1, 2, 3) // ok

    Perl should implement javascript subroutine signatures at first step.

  • Yuki Kimoto commented on I think subroutine signatures don't need arguments count checking

    and PHP

    function foo($x, $y) {

    }

    foo(1) // ok
    foo(1, 2) // ok
    foo(1, 2, 3) // ok

    I like JavaScript and PHP way. This is natural.

  • weissel commented on I think subroutine signatures don't need arguments count checking

    Hmmm.

    Yuki, you seem to have a strong opinion here.
    Not that there is anything wrong with having strong opinions --- but it would be much better if you could at least point to some facts that support your opinion.
    Like, say, benchmarks. Like, say, code (show the source code!) that does run appreciably faster without argument checking.

    Performance at all costs of programmer usability, maintenance and bug finding ease would mean that you write highly optimized, hand-polished assembler running on the bare metal of the machine, with no OS to slow things down…

Subscribe to feed Responses to Comments from mauke

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.