|
|
|
|
|
by isostatic
2515 days ago
|
|
I usually do sub mymethod($$)
my ($arg1, $arg2) = @_;
}
Apart from on the smallest programs. So it does have a method signature (obv it's an untyped language)There are shortcuts (just like you could write "doSometing() unless $var;"). Perl does give you options. Python has different options for passing methods - passing variables, passing a dict, P.S. while looking at python method declartions, you can send variables, a key-value, multiple keyvalue, and then there's this: https://stackoverflow.com/a/16785702 Which comes out with f = lambda **dic: ' '.join(dic.get(key, 'None') for key in 'abc')
Which is no more or less readable than the most confusing perl I've ever encountered."Cool Shortcuts" are a problem in any language. There are values in anonymous functions on occasion (especially in sorts), there should be a very compelling reason to do so. |
|
That does not work. Prototypes are ignored for method calls. You are expected to not abuse prototypes for signatures as they serve a different purpose.
> it's an untyped language
That's wrong even with the most lenient/charitable interpretation. Using an unexpected type of data is a fatal error.
Type constraints have existed for a very long time, for example see http://p3rl.org/Kavorka::Manual::Signatures#Type-constraints