logoalt Hacker News

jstanley08/01/20253 repliesview on HN

> I don't miss perls halfarsed function args.

You mean you don't like writing things like...

    sub foo {
        my ($a, $b, $c) = shift;

?

Replies

KaiserPro08/01/2025

Indeed!

It just grinds my gears that _I_ need to check to see if the caller has given me all the required bits. That seems like something the language should do.

I understand that it does give you a lot of flexibility, but Hnnnnnnnnn

(from what I recall object oriented perl doesn't give you this flexibility, but I'm not sure, as I never really did it. )

show 1 reply
oneshtein08/01/2025

  Yes, I hate to write

  sub foo($$$) {
    my ($a, $b, $c) = @_;
  }
Where @_ is array of arguments, and ($$$) is function prototype (3 scalars are expected).
show 2 replies
AndrewDavis08/01/2025

Not sure if you've deliberately put in two bugs there haha

1. shift only shifts off the first element.

2. (if classify this as a bug) using $a and $b are frowned upon because they're the default variables when using sort.

show 2 replies