in reply to Hello Perl 6. Running pugs on Windows

Are you sure you want to mess around with multimethod dispatch? I mean, it is a pretty complex thing. Just look at the sheer amount of definition in Apocalypse 12. It's implementation is by far non-trivial, so I am not really shocked that it does not work as expected...:-)

But if you do want multimethod dispatch, why immediately starting with a corner case? I am not sure that empty argument lists are supported (or even considered) in multi subs, as these are distinguished based on their signatures (long names). What is the signature of an empty argument list then?

rg0now

  • Comment on Re: Hello Perl 6. Running pugs on Windows

Replies are listed 'Best First'.
Re^2: Hello Perl 6. Running pugs on Windows
by stvn (Monsignor) on Feb 16, 2005 at 14:52 UTC
    But if you do want multimethod dispatch, why immediately starting with a corner case?

    This may be a corner case for multi-method dispatch. But this kind of argument pattern matching (and by pattern matching I dont mean reg-exp) is quite common in functional languages, especially in recursive functions. Consider this these list functions in Standard ML, they all have an empty list case;

    fun prod [ ] = 1 | prod (h::t) = h * (prod t); fun sum [ ] = 0 | sum (h::t) = h + (sum t); fun length [ ] = 0 | length (h::t) = 1 + (length t);
    When pattern matching against arguments in recursive functions like this (and in rescursive multi-method dispatch) it is always good to consider (and explicity code for) your edge cases, otherwise you run the risk of infinite recursion.

    -stvn

      Exactly, and to provide another example, this time in Haskell. The quicksort that serves as a model for the code in my original node:

      qsort [] = [] qsort (x:xs) = qsort elts_lt_x ++ [x] ++ qsort elts_greq_x where elts_lt_x = [y | y <- xs, y < x] elts_greq_x = [y | y <- xs, y >= x]

      I really like the short and concise way this expresses the quicksort algorithm in almost mathematical notation. Although math was never my strong point, this way of talking about sets and their behaviour is in my opinion very powerful. Take a look at this node for some examples that are a bit closer to home.

      pernod
      --
      Mischief. Mayhem. Soap.

Re^2: Hello Perl 6. Running pugs on Windows
by pernod (Chaplain) on Feb 16, 2005 at 11:43 UTC
    But if you do want multimethod dispatch, why immediately starting with a corner case?

    Because that quicksort implementation is cool :) I must admit that I haven't read all the apocalypses (I try from time to time, though), so I don't know much about the inner workings of what I'm attempting. I was just curious to see whether that neat Haskell snippet worked in Perl too.

    pernod
    --
    Mischief. Mayhem. Soap.

      Your post made me pretty much enthusiastic about Pugs, so I also gave it a try. Nice to see some Perl6 in work...

      Although, neither I had luck with multiple dispatch. It seems to be broken in the current svn tree. What makes me think this is that I tried some of the sample codes at the FeatherweightPerl6 website to make work, but to no avail. I tend to get similar errors like you...

      rg0now