in reply to Re: Constant code
in thread Constant code

The simple answer here is to call sub1() and sub2() with no arguments, use sub1(), etc. Don't use a bare word sub name for a normal user defined sub/function.

And yet, we encourage this all the time in OO paradigms, where we have a member function foo to get the value of 'foo': $obj->foo instead of $obj->foo(), ostensibly because it is a 'value' and the fact that foo is a function is just an implemention detail.

Fooey, I say: if you end up creating a stack entry, use parens. That's just my curmudgeonly USD 0.02.

Replies are listed 'Best First'.
Re^3: Constant code
by Anonymous Monk on Jan 20, 2017 at 22:15 UTC

    I have seen parentheses-less method calls outside of getting only a (variable) value, namely in cases where no parameters are being passed. (I don't have any examples handy right now.)

Re^3: Constant code
by mpersico (Monk) on Jan 20, 2017 at 21:02 UTC
    Sorry, that ^ was me.

      I admit this is a bit of a syntactic nit, but in the  $object_reference->method and  ClassName->method OO cases, doesn't the  -> operator as unambiguously indicate function invocation (both to compiler and to programmer) as the parentheses in the  func() case? I.e., always writing  $obj->method without any parentheses is the same as always writing  func() with its empty parentheses. (Although I certainly agree that  $obj->method() is perfectly valid.)


      Give a man a fish:  <%-{-{-{-<