http://qs1969.pair.com?node_id=1173981


in reply to Re^2: Static method vs virtual method
in thread Static method vs virtual method

Doesn't this advice directly contradict the advice of lakshmananindia, who states that new() should be static? It seems that there is a lack of consensus on whether new() should be static or virtual. This is a real problem, because no facility is provided to force the caller to invoke new() the correct way by producing an error if the invocation is wrong.

Replies are listed 'Best First'.
Re^4: Static method vs virtual method
by choroba (Archbishop) on Oct 14, 2016 at 08:28 UTC
    No. Static doesn't mean "ignoring the first argument", it means "expecting the class name as the first argument". Moreover, in Perl, you can create methods that are both static and virtual (the question is why).

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,