From: chromatic (via RT) <[EMAIL PROTECTED]>
   Date: Sat, 25 Oct 2008 18:21:26 -0700

   # New Ticket Created by  chromatic 
   # Please include the string:  [perl #60124]
   # in the subject line of all future correspondence about this issue. 
   # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=60124 >

   I expect this code to dispatch properly; autoboxing works and :optional 
   parameters work, at least separately.  When combined, they appear not to 
   work.

I think this is purely an autoboxing+MMD issue:  The following
simplified version fails in the same way, even without the :optional
param:

        .sub 'main' :main
                foo('Hello')
        .end
        .sub foo :multi(String)
            .param pmc s

            say s
        .end

but supplying a PMC as the first arg make it work again:

        .sub 'main' :main
                $P0 = new 'String'
                $P0 = 'Hello'
                foo($P0)
                foo($P0, 1)
                $P1 = new 'String'
                $P1 = 'Goodbye'
                foo($P1, 2)
                $P2 = new 'Integer'
                $P2 = 1
                foo($P2)
                $P3 = new 'Integer'
                $P3 = 100
                foo($P3, 200)
        .end

This gives your expected output, using the same multis with :optional
params from your version.

   Which brings us to an interesting question:  How can you decide what
type to use for autoboxing before you've determined the actual sub
you're going to call?  And how can you find the sub without having the
correct dispatch types up front?

   I suppose the Alexandrian solution would be to determine what types
the HLL of the multi would use to autobox everything that needed it, and
dispatch on those.  That might be kinda weird if the actual autobox
operation during parameter passing picked a different type, especially
if it was incompatible with the dispatch type . . .

   HTH (but have no time to take it further),

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/

Reply via email to