On Sat, 27 Mar 2021 04:47:48 +0100, Eirik Berg Hanssen <Eirik-Berg.Hanssen@allverden.no> wrote: > On Sat, Mar 27, 2021 at 4:35 AM Darren Duncan <darren@darrenduncan.net> wrote: >> So which of these is considered better code? >> >> Functional design: >> >> my $result1 = op2(op1($input1)); >> >> my $result2 = [map { op2(op1($_)) } @{$input2}]; >> >> Procedural design: >> >> my $result1 = $input1; >> op1($result1); >> op2($result1); >> >> my $result2 = []; >> foreach $elem (@{$input2}) >> { >> op1($elem); >> op2($elem); >> push(@{$result2}, $elem); >> } > > I don't think anyone is arguing for the latter. Try this instead: > > Chomp-like design: > > op2(op1(my $result1 = $input1)); > > op2(op1(my @result2 = @input2)); > > > Eirik I explained this in the github issue already. That is cute but doesn't compose in map/grep/anonymous argument list processing chains. For that you need argument returning. At the same time argument returning version isn't useful for: while(<>) { tromp; ...; } (or whatever the accurate form is) For Perl we need BOTH trim and tromp and there is zero way around this unless you're willing to fuck some users up for no good reason. The only real question is the names. -- With regards, Christian WaldeThread Previous | Thread Next