2 ms·
> bolted on, awkward params passing Shell had to do this because of shell reasons, like how you need spaces where you shouldn't. Perl post-dated C by over a de
by dehrmann 10mo ago
> bolted on, awkward params passing
Shell had to do this because of shell reasons, like how you need spaces where you shouldn't. Perl post-dated C by over a decade, so there was no reason for goofy argument unpacking.
- ojosilva 10mo agoYes there was a reason as Perl took inspiration from Lisp - everything is a list- and everyone knows how quick C's variadic arguments get nasty. So @_ was a response to that issue, given Perl was about being dynamic and not typed and there were no IDEs or linters that would type-check and refactor code based on function signatures. JS had the same issue forever and finally implemented a rest/spread operator in ES6. Python had variadic from the start but no rest operator until Python3. Perl had spread/rest for vargs in the late 80s already. For familiarity, Perl chose the @ operator that meant vargs in bourne shell in the 70s.
- colinstrickland 10mo agoAlthough Perl auto flattens lists by default, which isn't particularly lisp like.
- tmtvl 10mo agoPerl was developed in 1987, the first Common Lisp standard was released in 1984, 3 years earlier. Common Lisp allows arguments like so: (defun frobnicate (foo &key (bar (Vector 1 2 3)) (baz 'quux)) (declare (type Foo foo) (type (Vector Integer) bar) (type Symbol baz)) ...) Not only normal arguments like we get in C or Pascal, but there's keyword arguments, you can have optional arguments, and a rest argument, which is most like Perl's @_. And that's not even getting into destructuring lambda lists which are available for macros or typed lambda lists for methods.