develooper Front page | perl.perl5.porters | Postings from September 2011

Re: Package:: still ambiguous

Thread Previous | Thread Next
From:
Stevan Little
Date:
September 14, 2011 11:22
Subject:
Re: Package:: still ambiguous
Message ID:
C06D8943-5C9B-4E96-9F91-72BF33FE7503@iinteractive.com

On Sep 14, 2011, at 12:02 PM, Zefram wrote:
> Stevan Little wrote:
>> How do you handle inheritance?
> 
> Put package object ref into @ISA.  @ISA would be one of many places
> where a package can be referenced either by name or by object ref,
> like the second argument to bless().

Yeah, I think this would have to be the only way, assuming we stuck 
with @ISA being a magical variable. 

>> My (limited) understanding of the mro functionality is that it is still
>> very tied to string lookup for package names.
> 
> That can change.  However, with the concept of weak-ref package names, it
> could still use the names for identification (as hash keys, for example),
> as long as it hangs onto the package object somewhere appropriate.
> Of course, it'll take some care to avoid the MRO system making packages
> live longer than they should.

Yes, this could get messy, either you would have to destroy each MRO when 
the class using it was itself destoryed (which kind of implies that each 
class has it's own private MRO list, and I am not sure that is how it 
is/would be done), or you would have to do some kind of "mark-and-sweep" 
run over all the MRO lists that are in memory and clear things appropriately.

>> Additionally, I am not so sure that blessing the package "object" into 
>> itself is not an abuse of bless, which while it might work, is just 
>> another bit of Perl OO weirdness that would lead to problems down the 
>> road.
> 
> Yeah, I'm not sure about that either.  It's an attempt to run with the
> class/instance method duality.  It's kinda neat, but also weird.

Honestly, I think the whole class/instance method duality is a real problem. 
It has encouraged all sorts of (IMO) bad OO techniques that have taken root 
in Perl. This is also not something you find in other languages, because 
most other languages have a sensible notion of what is a class vs. what is
an instance. I am all for trying to solve this problem, however I am not 
sure it truly can be solved within the context of traditional Perl 5 OO 
as it stands right now without breaking backward compat.

That said, clearing up the package ambiguity would help.

- Stevan












Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About