develooper Front page | perl.perl5.porters | Postings from June 2021

Re: Not an OO RFC, take 2

Thread Previous | Thread Next
Nicholas Clark
June 23, 2021 05:41
Re: Not an OO RFC, take 2
Message ID:
On Sun, Jun 20, 2021 at 08:00:47PM -0400, Chris Prather wrote:

> Taking a cue from Nicholas, I've re-organized your email to make my reply

I'm finding it slightly unsettling how many folks are quoting me these days.
I'm pretty sure I'm not the messiah. I'm far more likely to be the "naughty
boy" (or at least, the semi-professional trouble maker/agent provocateur)

I intended to demonstrate this below:

> I'm pretty convinced you cannot have both, because the existing tooling in Perl
> is not fit for purpose. Perl has no concept of Records[1], or user-defined data
> structures. Perl has five (or seventeen if you read perlapi) kinds of data
> structure that can be blessed into an object. Those are the only kinds you can
> have.


Surely it's (at least) six. The obvious four are scalars, AV, HV and CV.

And then I can bless FORMATs:

$ perl -MDevel::Peek -e 'format STDOUT =' -e 'Hello world' -e. -e '$a = bless *STDOUT{FORMAT}, "gotcha"; Dump($a); Dump($$a)'
SV = IV(0x55a5662801c0) at 0x55a5662801d0
  REFCNT = 1
  RV = 0x55a566280218
  SV = PVFM(0x55a56628e9d0) at 0x55a566280218
    REFCNT = 2
    STASH = 0x55a5662536a0      "gotcha"
    COMP_STASH = 0x0
    START = 0x55a5662bf180 ===> 1
    ROOT = 0x55a5662bf108
    GVGV::GV = 0x55a5662775f8   "main" :: "STDOUT"
    FILE = "-e"
    DEPTH = 0
    FLAGS = 0x1000
    OUTSIDE_SEQ = 162
    PADLIST = 0x55a566285580
    PADNAME = 0x55a566272520(0x55a566285cf0) PAD = 0x55a5662801a0(0x55a566286df0)
    OUTSIDE = 0x55a5662538e0 (MAIN)
Not a SCALAR reference at -e line 4.

and IOs:

$ perl -MDevel::Peek -e '$a = bless *STDOUT{IO}, "gotcha"; Dump($a); Dump($$a)'
SV = IV(0x55ac738d81f8) at 0x55ac738d8208
  REFCNT = 1
  RV = 0x55ac738d7c08
  SV = PVIO(0x55ac738d6d78) at 0x55ac738d7c08
    REFCNT = 3
    STASH = 0x55ac738ab6a0      "gotcha"
    IFP = 0x55ac738cabd0
    OFP = 0x55ac738cabd0
    DIRP = 0x0
    LINES = 0
    PAGE = 0
    PAGE_LEN = 60
    LINES_LEFT = 0
    TOP_GV = 0x0
    FMT_GV = 0x0
    BOTTOM_GV = 0x0
    TYPE = '>'
    FLAGS = 0x0
Not a SCALAR reference at -e line 1.

and whilst I can bless PVGVs, they behave roughly like scalars, so I wasn't
counting them.

(Sadly I can't see how to split apart file handles and directory handles, so
I can't see how to bless them separately)

> Finally since there is a lot of yelling about the Elephant in the Room: Perl's
> relative market share isn't a problem for perl5-porters. It's not a problem
> perl5-porters can or should attempt to solve. A new object system with real

I'm sort of disagreeing. It's not a problem that we should directly solve.
But we shouldn't hinder folks who are usefully trying to solve it, as it is
to our benefit that they prosper.

I hope that I didn't undermine *too* much that you were trying to say :-)

Nicholas Clark

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