On Tue, Dec 10, 2002 at 11:37:58AM -0800, David Whipp wrote:
> I was reading the "Partially Memorized Functions" thread, and the thought
> came to mind that what we really need, is to define a different
> implementation of the method for a specific value of the arg. Something
> like:
> 
> sub days_in_month( Str $month, Int $year )
> {
>   ...
> }
> 
> sub days_in_month( Str $month is value{ rx:i/feb[ruary]?/ }, Int $year ) is
> cached
> {
>   ...
> }

That strikes me as a lot of bugs waiting to happen.

What happens when you have multiple values that would match a given
parameter?

What happens when some module you don't even see loads a variant
of a sub you declare that matches some of the arguments you expected
to process?


XSLT has something similar.  The rules are subtle and easy to mess
up.  The XSLT spec also states that defining multiple subs (templates)
that could match a piece of input is an error, but may be resolved
by a specific algorithm (last definition prevails).  I'm not so
sure I like that behavior in Perl; it's all too easy to create new
subs at runtime...

Z.

Reply via email to