Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Perl doesn't require "()" after the name of a function to call the function. In fact, parentheses aren't required for function calls at all.

The code:

    use strict;
    use warnings;
    
    sub foo { print "In foo\n"; print "args = " . join(",",@_) . "\n" if @_; }

    foo;

    foo "a", "b", "c";
yields the output:

    In foo
    In foo
    args = a,b,c


Neither does ruby.

(Which is really really confusing if you spend your days in python, and occasionally have to edit something in ruby.)


It's even more confusing if you have to figure out if you're calling a method or referencing a variable.

The code could be assigning a new variable from a method return value, or just from an existing variable.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: