This is a message primarily for Chip --

Question:  As a possibly useful optimization, can we declare 
that :slurpy parameters can also be :optional, as in...?

     .param pmc argv          :slurpy :optional
     .param int has_argv      :opt_flag

     .param pmc modifiers     :slurpy :named :optional
     .param int has_modifiers :opt_flag

Rationale:

Normally one would just use :slurpy, and if there aren't any
"extra" arguments then the slurpy array or hash would simply
be constructed as an empty container or hash.  That's great.

But many times the call profile is likely to be such that
extra arguments to the sub are a rarity instead of the norm,
and in these cases it may be worth avoiding the overhead of
creating an empty array or hash that isn't likely to get
used.

This is the case with PGE, where subrules need to be able to
receive modifiers and pass modifiers to other subrules.
(The :keepall modifier is probably the most obvious example,
but there are others.)

Since we don't know in advance all of the modifiers that might
possibly be sent to a given rule subroutine, the sub needs to be able to
accept whatever it gets -- i.e., :slurpy.  But, since the
majority of actual subrule calls won't involve any extra 
parameters, creating the empty :slurpy array for each call 
seems like a lot of unneeded overhead.  Thus, perhaps we
could use the :optional flag on :slurpy params to say "don't
create the container pmc if no parameters arrive here".


I recognize this may be a premature optimization, and there's
certainly no problem with PGE being able to work without 
:slurpy :optional.  (We'll just create the empty arrays and hashes
for now.) But I did want to bring up the possibility
so you could fold it into any other plans or designs you might
have.

Thanks,

Pm

Reply via email to