Re: RFC 193 (v1) Objects : Core support for method delegation
[email protected] (Uri Guttman) Mon, 4 Sep 2000 18:17:15 -0400
| Newsgroups | perl.perl6.language.objects |
|---|---|
| Message-ID | <[email protected].> |
>>>>> "PRL" == Perl6 RFC Librarian <[email protected]> writes: PRL> One powerful application of delegation is as a replacement for PRL> inheritance where the internals of a prospective base class are PRL> inaccessible or inconvenient, or the base class was not designed PRL> to be inherited and yet it must be. isn't this a HAS_A type of relationship? i have plenty of these in my new project and it is a pain. i can't inherit as the objects are really not related but one uses the other, e.g. i have a high level obejct with a socket and a buufered_io object. i don't want to inherit from buffered i/o since its methods may collide with the main object. but some methods i want to be able to be passed to buffered i/o and have nothing to do with the main object. PRL> sub new { PRL> my ($class, $infile, $outfile) = @_; PRL> bless { PRL> in => IO::File->new($infile) || die, PRL> out => IO::File->new("> $outfile") || die, PRL> }, $class; PRL> } PRL> use Class::Delegation shouldn't that be use delegation? i think you have a cut and paste error. PRL> in => [qw( getline getlines getc ungetc eof read sysread PRL> input_record_separator input_line_number )], what about a way of delegating ALL the methods of an object? any way to signify that? in => 'ALL', will look up all current methods (maybe tagged?) from the class 'in' and handle that. then you don't have to update all the delegation calls each time the 'in' object changes. i like this RFC a lot. but i like most of damian's stuff. or at least what i understand. :-) uri -- Uri Guttman --------- [email protected] ---------- http://www.sysarch.com SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books The Best Search Engine on the Net ---------- http://www.northernlight.com