Since a class is just a module, this already cleanly falls out of the concept of currying modules, as described in S06. There it gives the example of:
(use IO::Logging).assuming(logfile => ".log");
So you can also presumably curry the invocants of all the methods:
constant $defobj = ...; (use Some::Class).assuming($defobj:);
Note however that this is much better than merely forcing the class to carry its own default object. Instead, we encourage the user module to declare its own default object and use that, which means that different modules can have different default objects, each lexically scoped to its own module. You can still have a global default object if you like, but all the modules that want to use that global default object will have to explicitly declare that that is what they want, rather than being forced to share whether they want to or not.

The particular syntax given above is a bit problematic in several ways, but even if the syntax changes, the principle will remain that you'll be able to use some form of currying to supply an aliased view of a module or class, and that mechanism will certainly allow you to curry the invocants of a class, essentially turning a class of methods into a module of subs that assume the curried invocant.

In any case, this is not a terribly new idea: the currying of classes into modules was already explicitly mentioned in A06 back in 2003.


In reply to Re: [Perl 6] auto subs from methods? by TimToady
in thread [Perl 6] auto subs from methods? by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.