Pre-PPC: class :abstract

[email protected] ("Paul \"LeoNerd\" Evans")
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
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).

  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.