[Mpls-pm] Closure Code Samples

Joshua ben Jore twists at gmail.com
Wed Oct 19 09:24:59 PDT 2005


On 10/19/05, Robert Fischer <rfischer at corradiation.net> wrote:
> They force context, catch errors like sin($a,$b,$c), do implicit
> referencing, and prevent errors like "PI-1" becoming "PI(-1)", all of
> which are major annoyances that you encounter without prototypes.  I
> consider doing that a whole lot, and decidedly not useless.

I suppose its worthwhile to note that prototypes are occasionally
useful to get things like inlined constants or when in trickery, to be
able to omit the `sub ' from `foo { ... }'. Beyond that, I've just
found it unhelpful to have my calling syntax dictated by the function.
That is, instead of being able able to say foo( ... ) where ... is
going to be a list of the proper form, I have to start specifying
every parameter individually.

Recently, for a one-liner, having rename($$) was extremely
inconvenient. I wanted to write perl -e 'rename /((.+\.xml)\.bck)/ for
<*>' because it was short. I recall in the past, as a newbie that
having arrays be passed in scalar context was incredibly confusing.
That shot a day while I learned where my mistake was.

I'm just not so perfect that I can have those context-conversion
prototypes around. They're a source of strange behavior and I would
usually prefer my perl to be a bit more consistent about how it
operated (unless I've declared something unusual in the vicinity).
So... they help me to write buggier perl. If they help you write
better perl, I guess that's good enough.

That said, I really do wish perl had better parameter lists and that
if I wished, I could get typed variables.

Josh


More information about the Mpls-pm mailing list