http://www.perlmonks.org?node_id=434985


in reply to Re: Perl6 dot syntax (for methods?)
in thread Perl6 dot syntax (for methods?)

Basically @array is an object (everything is an object).

Oh my, now I am getting even more confused...

(1, 5, 2, 4, 3).quicksort.say;

So, quicksort and say are methods of the array class? Or of the base object class? Because if they are not, I think the normal functional syntax is more appropriate. Especially if everything is (or can be treated as) an object, should we not be extra careful about what really is a method and what is not?

Replies are listed 'Best First'.
Re^3: Perl6 dot syntax (for methods?)
by chromatic (Archbishop) on Feb 28, 2005 at 07:46 UTC

    They are methods of the list class, at least here, at least as far as I understand it.

    My understanding is also that the operator forms multi-dispatch to the appropriate methods according to their arguments.

Re^3: Perl6 dot syntax (for methods?)
by gaal (Parson) on Feb 28, 2005 at 07:37 UTC
    FWIW, you can do this sort of thing in Perl5 as well; see autobox.
Re^3: Perl6 dot syntax (for methods?)
by rg0now (Chaplain) on Feb 28, 2005 at 13:50 UTC
    So, quicksort and say are methods of the array class? Or of the base object class?

    I think both of them are methods of the array abstract base class. I mean, similar semantics and syntax is pretty common, and very familiar in other scripting languages. At least, Python does this:

    >>> q=[2,3] >>> p=[1,q,3] >>> p[1].append('xtra') >>> p [1, [2, 3, 'xtra'], 3]

    rg0now