Re: Pre-PPC: class :abstract

[email protected] (Branislav Zahradník)
Newsgroups perl.perl5.porters
Message-ID <CAB=rbOkmopGdwS-ftj7tiF5oNBibNvA3OqvoOMHt9Kid8Tsj0g@mail.gmail.com>
On Wed, 17 Dec 2025 at 15:38, Paul "LeoNerd" Evans <[email protected]>
wrote:

> I've been thinking about what next to work on for the core `class`
> feature. One thing I think would be fairly easy to add, would be a copy
> of Object::Pad's abstract classes and required methods.
>
> The idea of an abstract class is documented in Object::Pad thusly:
>
>   :abstract
>
>   Declares that this class is abstract. An abstract class is permitted
>   to define required methods (i.e. named methods without a body
>   definition).
>

I always though that abstract has same usefulness as Java's final - hardly
to be distinguished from zero.

If you don't want to create it as a class, create it as a role.
or "method foo = 0"
or "requires method_not_implemented_here"

Fixing badly placed abstract (or final in Java's case) is lot of pain.


>
>   Instances may not be created of this class type directly. Instead, a
>   subclass of this class must be derived that provides method bodies for
>   any of the named required methods. Any subclass of an abstract class
>   must either provide bodies for all remaining required methods, or
>   themselves be declared :abstract as well.
>
>   This provides a way in which a generic type of class can be created,
>   that is intended for multiple different specialisations to further
>   define different kinds of behaviour by providing bodies for those
>   named methods. Being abstract means that instances cannot be created
>   of this as-yet-incomplete class type.
>
>     -- https://metacpan.org/pod/Object::Pad#%3Aabstract
>
> One slight difference from Object::Pad's design that I'm still
> considering on is whether to say that required method declarations in
> such a class body have to have an attribute on them as well, just to
> make them stand out a little more visually. Without it it might be hard
> to notice when they're being used.
>
> These would be quite an easy stepping-stone away from where we are now,
> allowing people to build quite a few more shapes and patterns. I've
> certainly found them useful when building things on Object::Pad. It also
> avoids the overall problem of "roles" being far too ill-defined and I
> still have no idea what people want there. (*AHEM*)
>
> How do we feel about these? Shall I write up a proper PPC doc on this?
>
> --
> Paul "LeoNerd" Evans
>
> [email protected]
> http://www.leonerd.org.uk/  |  https://metacpan.org/author/PEVANS
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.