4 ms·
I mentioned it in another comment, but a really obvious one is that functions in Perl don't have parameters. Every function just takes in a list, and can do wha
by mkozlows 7y ago
I mentioned it in another comment, but a really obvious one is that functions in Perl don't have parameters. Every function just takes in a list, and can do whatever it wants with that list. This page gives a good overview of the situation: https://perl101.org/subroutines.html https://perl101.org/subroutines.html
There's a kind of elegant flexibility to that, but it also makes it really hard to program reliably in the large, to build useful tooling, or even to glance at a function and know what you should pass it.
Beyond that, classic Perl was full of things that make it quick to write small programs (as CGI scripts were at the time) without a lot of boilerplate, but which don't scale up.
(Perl 6 is very different, and has an almost comically flexible/powerful function signature system (https://docs.perl6.org/type/Signature https://docs.perl6.org/type/Signature). Whether or not you like Perl 6's stuff, it's nothing at all like Perl 5's.)
- bmn__ 7y ago> functions in Perl don't have parameters Sorry, you are misinformed. That hasn't been true for a long time, see http://p3rl.org/Kavorka::Manual::Signatures http://p3rl.org/Kavorka::Manual::Signatures Other languages would kill for this kind of beyond-complete maximum overkill feature set. > This page gives a good overview of the situation: https://perl101.org/subroutines.html https://perl101.org/subroutines.html No, it doesn't. That page is not wrong, but incomplete and teaches the wrong stuff, wouldn't recommend. Instead see http://perl-tutorial.org/ http://perl-tutorial.org/ for recommended tutorials.
- rubinelli 7y agoFrom the Perl 5.30 documentation: > WARNING: Subroutine signatures are experimental. The feature may be modified or removed in future versions of Perl. https://metacpan.org/pod/perlsub https://metacpan.org/pod/perlsub
- mmcclimon 7y agoIt's true that they're experimental, but it's extremely unlikely they'll be removed. The only reason they weren't stable in the most recent version of perl is because of some interactions with subroutine attributes (specifically, :lvalue) which needed some tweaking. We use them everywhere at Fastmail and they're great. Which is to say: a lot of the reason they're still experimental is because Perl's commitment to backward compatibility. Other languages might have said "oh well," but Perl 5 said "oh, an unintended consequence that might break real uses in the wild; we should wait another year."
- iosonofuturista 7y agoSo, the first tutorial on the list that you recommend has this page for functions[0]. It's more or less the same as GP's link. YOU are the one misinforming, it would seem. Granted, I don't work with perl (5, never tried 6) for about 15 years, but most criticism of it seems to align with my experiences back then. [0] http://mvp.kablamo.org/basics/functions/ http://mvp.kablamo.org/basics/functions/ Edit: The second [1] also recomends the @_ method, and the third [2] the shift method. Did you even read your own links? [1] https://perlmaven.com/subroutines-and-functions-in-perl https://perlmaven.com/subroutines-and-functions-in-perl [2] https://learnxinyminutes.com/docs/perl/ https://learnxinyminutes.com/docs/perl/ (search for subroutines)
- marcosdumay 7y agoIn my experience, I never got positional parameters to reliably work on Perl5. They were always buggy and would break with completely unrelated changes. On Perl6 those are officially supported, so I imagine they work.
- xorcist 7y agoThere is a certain elegance to bare lists, as any lisp programmer will probably agree with. It enables the programmer to build their own abstractions as they go. That is also true for the overly simple object model of Perl 5, it is more like an OOP construction kit, which enables things like Moose which has for almost 15 years provided Perl 5 with a very flexible object model. It would be very interesting to know if anybody knows of similar systems for other languages? Large OO codebases can be downright nasty to navigate and while I have never had the opportunity to use something like Moose for large scale projects I imagine that's where it would shine.