develooper Front page | perl.perl5.porters | Postings from August 2022

Pre-PR Preview of `use feature 'class'`

Thread Next
Paul "LeoNerd" Evans
August 1, 2022 21:22
Pre-PR Preview of `use feature 'class'`
Message ID:
TL;DR: A list of what's present, what's still to do, and how you can
  help me get it all into shape

Hi all,

While my branch is still some way from being PR-ready, I thought I'd
draw a little more attention to it, and invite people to take a look at
the work so far, while it takes shape.

It is currently missing any documentation, and has only a small
scattering of unit tests of basic functionality. However, most of the
groundwork for the underlying shape of how I'm suggesting to implement
the idea of classes/methods/fields is now present, and unlikely to
change *all* that much in the course of continuing to expand and add
more features, so now might be a good time to get some new eyeballs on

As a quick 30-second walkthrough, the attached notes might be helpful
to understand what is currently present - and more importantly, how it
is implemented.

That's the current limit of the work in the branch at time of writing.
There's a few more things still that need doing even before we consider
this first stage complete:

  *) Object instances are currently SVt_PVAVs directly, with fields
     accessible by index within them. This technically works but isn't
     suitable for a real implementation because it would allow direct
     access by inspecting `@$obj` on such an instance - and would also
     leak plain AVs and HVs into Perl space because they're not wrapped
     in RVs.

     This definitely needs fixing, by adding a new SV type. It turns
     out that's slightly nontrivial because there's a place where SV
     types are stored in a 4-bit integer, and adding a new type would
     be number 16. Oops. I'm still working on a fix here.

  *) Unit classes, as mentioned in the notes.

  *) Lots of tests need writing - both of things we expect to work, and
     sanity tests to ensure the things we expect not to work indeed
     complain in a sensible way and don't break.

  *) Lots and *lots* of new documentation needs writing.

These latter two in particular are things everyone else can help me
with. :)

The branch is still in somewhat of a state of flux, so I'll keep
force-pushing it with rebase updates from blead, but if you don't mind
that feel free to check it out and build it yourself - it shouldn't
need any special handling to actually build and install. Having done
that you'll find you have a new named feature:

  $ bleadperl -Mexperimental=class -E \
    'class Hello { method greet { say "Hello, world" } }
  Hello, world

Have a play with it, try to find ways to break it and send me test

Or find interesting things that do work and you think should be
supported and properly tested - send me more test cases.

Or have a go at writing some documentation for it. It doesn't matter if
it's not factually correct - I can easily fix factual inaccuracies in
the wording. I just find it very hard to actually begin writing a new
document for this kind of thing (What should it be called? What's the
opening sentence? What mood and tone are the opening paragraph of
English Waffly Words written in..? etc...) - this is something I'm sure
a lot of people could do far better than I can.

Or finally - have a look over the implementation parts of notes, and
the code in the branch, and give me some feedback on what people think
of the overall way it's been implemented internally. Because core can
do a lot of things that no CPAN module can do, I took a whole new
approach to implementing this than was possible with the Object::Pad
testbed, so all of these internal design decisions are entirely new and
untested from there. It'd be great to get some feedback on whether this
seems like a direction that folks are happy to support for the next $N

Thanks all,

Paul "LeoNerd" Evans      |  |

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About