Subtle advantage of @_ ?

It eliminates method polymorphism.
Makes it simple for over-riding inherited method, as there is only one method.
Now that makes Liskov Substituion simpler to implement.


But that’s only simpler from the point of view of perl, but not that of Perl code. Instead of writing several candidate methods with different signatures and letting the dispatcher pick one of them – declaratively –, you throw away the dispatcher and let the Perl programmer unpack @_ and inspect it to choose a branch – imperatively.

And Liskov substitution is not about passing the compiler’s bar. It’s about whether the semantics are preserved. So it is completely unrelated to how a programming language. Static or dynamic types, explicit or implicit, weak or strong, signature overloading, multiple dispatch… you name it, and none of it makes a whit of difference. The question isn’t “will the compiler let me do this?” (because if it doesn’t, the program won’t compile in the first place, so none of this deliberation is necessary) – the question is “the program may be valid, but will it do something reasonable, or does it have subtle semantical inconsistencies at a level that is inaccessible to the compiler?”.

Leave a comment

About [deleted]

user-pic I blog about Perl.