develooper Front page | perl.perl5.porters | Postings from October 2016

[perl #129967] [PATCH] Add @ISA to perlvar

Thread Previous | Thread Next
Father Chrysostomos via RT
October 31, 2016 15:42
[perl #129967] [PATCH] Add @ISA to perlvar
Message ID:
On Mon Oct 31 04:02:09 2016, wrote:
> Hi,
> On 31.10.2016 06:39, Father Chrysostomos via RT wrote:
>  > On Sun Oct 30 17:51:24 2016, tonyc wrote:
>  >>
>  >> +It is possible to manually set C<@ISA>, but it is recommended to use
>  >> +L<parent> to declare parent classes.
>  >>
>  >> Is it recommended?
>  >
>  > By some and not by others.
> I copied that wording from perlobj: "It is possible to manually set 
> @ISA, and you may see this in older Perl code. Much older code also uses 
> the base pragma. For new code, we recommend that you use the parent 
> pragma to declare your parents. This pragma will take care of setting 
> @ISA. It will also load the parent classes and make sure that the 
> package doesn't inherit from itself."
> But that could certainly be toned down, see updated text below.
>  >> This pragma will take care of setting
>  >> +C<@ISA> and will also load the parent classes and make sure that the
>  >> +package doesn't inherit from itself.
>  >>
>  >> Setting @ISA directly also checks for recursive inheritence:
>  >>
>  >> $ ./perl -e 'package Foo; our @ISA = "Bar"; package Bar; our @ISA =
>  >> "Foo";'
>  >> Recursive inheritance detected in package 'Bar' at -e line 1.
> Having never set @ISA manually (at least as far back as I can 
> remember...) I did not know that, thanks!
>  > I think it would be better for perlvar to begin by explaining what
>  > the variable does and what it is for, and *then* also mention that
>  > *can* be used to set it.
> The patch begins with an explanation of the variable's purpose which I 
> again mostly copied & adapted from perlobj. It doesn't discuss MRO but 
> links to perlobj. I'll gladly take any suggestions there.
> Updated suggestion:
> ---8<---
> Each package contains a special array called C<@ISA> which contains a 
> list of that class's parent classes, if any. This array is simply a list 
> of scalars, each of which is a string that corresponds to a package 
> name. The array is examined when Perl does method resolution, which is 
> covered in L<perlobj>.
> It is possible to manually set C<@ISA>, or you can use L<parent> to load 
> and declare parent classes. Alternatively there is the L<base> pragma, 
> but that is discouraged unless you're also using the L<fields> pragma.
> --->8---
> If that's better I'd be happy to produce a new patch.

I do think that is better.  Thank you.


Father Chrysostomos

via perlbug:  queue: perl5 status: open

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