develooper Front page | perl.perl6.language | Postings from March 2005

Re: some misc Perl 6 questions

Thread Previous | Thread Next
David Storrs
March 9, 2005 07:46
Re: some misc Perl 6 questions
Message ID:
On Tue, Mar 08, 2005 at 10:29:30PM -0800, Darren Duncan wrote:
> [...]
> By using subtypes in this way, I could remove a lot of explicit input 
> checking code from my methods, which is great.  Also, the "where 
> clause" is not being repeated for every argument or attribute or 
> variable declaration.  (I like SQL domains for the same reasons.)

That's very cool.  I start to see the appeal of AOP.

> New question: Is there a way to say that two classes have a 
> privileged relationship, sort of like a marriage, such that each can 
> see and/or change otherwise private attributes in objects of the 
> other class, and yet the attribute list of each class is completely 
> different from the other?  Neither of the two objects is a subclass 
> of the other, nor fulfills a role defined by the other.
> Also, does my request sound like something that would be reasonable 
> to do, or a bad practice to avoid?

FYI, in C++, the keyword 'friend' precisely describes the relationship
you are discussing (and appears to be homologus to P6 'trusts').
There are good and bad things to be said about these relations but,
IME, they are usually used because they have to be in order to achieve
certain behavior, not because it is the cleanest or most appropriate
way to build the model.

Therefore, I would be very cautious about using 'trusts'.  YMMV.



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