I'm afraid we have to live with the overhead...
There is another alternative. Don't use named parameters.
Why does anyone use named parameters?
Let's see. How many of these languages do you think use named parameters at the call site?:
ABC ACSL Ada Alef Algol Algol68 APL AppleScript AutoIt Autolisp Awk BASIC BCPL Befunge BETA BLISS BLooP C C# C* C++ Cecil CFML CHILL Cilk CLAIRE Clean CLU CMS-2 COBOL Common Lisp Concurrent Clean Concurrent Pascal CORAL 66 CorelScript csh CSP cT Curry Dylan Dynace Eiffel Elisp Erlang Escher Esterel Euphoria FLooP FORMAC Forms/3 Forth FORTRAN FP Goedel GPSS Haskell Hope HyperTalk ICI Icon INTERCAL Interlisp J Java JavaScript Jovial Leda LIFE Limbo Lingo Lisp Logo LotusScript Lua Lucid M Magma Mathematica Mawl Mercury Miranda ML Modula 3 Modula-2 MUMPS NESL NIAL Oberon Objective-C Obliq occam OPS5 Orca Oz Pascal PerfectScript Perl PHP Pict Pike Pilot PL/C PL/I Postscript Prolog Python QBasic Quake-C REBOL Reduce Rexx RPG Ruby S Sather Scheme Self SETL sh Simscript SIMULA
50%? 10%, 5%, 1%, 2?
Even the much maligned VB Basic programmers seem to be able to write and maintain their code without this crutch. Why do Perl programmers suddenly feel the need for it?
I think that some time ago, someone found that they could do it. That a combination of Perl's syntax and hashes meant that it was possible. And kinda cute. And for complex constructors with lots of possible parameters, many optional, it makes a certain amount of sense. You mostly don't call heavy constructors in tight loops so there's no great harm in using it. For constructors.
But for most general purpose subroutines and method calls, the need for named parameters--ie. calls that take so many arguments that naming them is beneficial beyond an aid memoire for the casual tourist to the code--is strongly indicative of something seriously wrong in the design of the API.
Mostly, it is just as hard to look up the naming and spelling and casing conventions of named parameters when writing the calls, and just as hard to interpret the meaning of those names when reading them.
For most programmers in most languages, naming the positional arguments (formal parameters) within the sub or method is perfectly clear and effective. And Perl has that ability. And any edicts to force this upon Perl programmers is based on YAJ. (Yet another Justifiction.)
In reply to Re^4: When every microsecond counts: Parsing subroutine parameters
by BrowserUk
in thread When every microsecond counts: Parsing subroutine parameters
by snowhare
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |