Earlier quoted context omitted.
Thanks for that. First one (not 100% sure it's constant memory, I think perl optimises the for to avoid instantiating the (1..$n) list: #!/usr/bin/perl use Modern::Perl; use bigint; say fact(5000); sub fact { my ($n) = @_; my $output = 1; for my $i (1..$n) { $output *= $i; } return $output; } (Took the value up to 5000 to get something which ran long enough to get a measurement, on my laptop it runs (including startu…
that also highlights one of my perl peeves - having to scrape function args out of @_ rather than declaring them as part of the function definition.
And with @_, you're free to use positional arguments, named arguments, variable arity, etc. without penalty. Some languages only give you some of that.