Piers Cawley <[EMAIL PROTECTED]> writes:

> Michael G Schwern <[EMAIL PROTECTED]> writes:
> 
> > On Mon, Jul 02, 2001 at 04:18:31PM -0400, Michael G Schwern wrote:
> > > On Mon, Jul 02, 2001 at 12:59:51PM -0700, David Whipp wrote:
> > > > Its not quite the same thing, but Java does have the concept of
> > > > anonymous classes (it names them 'inner' classes): Is Perl6 going
> > > > to have a similar concept?
> > 
> > Okay, maybe I don't understand anonyous classes, but isn't this pretty
> > much the same thing:
> > 
> > package Foo;
> > 
> > {
> >     package My::Anon::Class;
> >     @ISA = qw(Whatever);
> >     sub new { ... }
> >     sub bar { ... }
> > }
> > 
> > sub new {
> >    my($class) = shift;
> >    my $anon = My::Anon::Class->new;
> >    ...
> > }
> 
> No. Need to be able to do:
> 
> my $anon = My::Anon::ObjectFactory->new(base => 'ClassName',
>                                         method1 => sub {...},
>                                         method2 => sub {...},);
> 
> Comes in very handy in Unit::Test, especially when you're writing
> tests to test the test harness...

Hmm.... that's not quite right, since you need to be able to pass in
arguments to the anonymous class's constructor...

    my $anon = My::Anon::ObjectFactory->new({base => 'Class',
                                             method1 => sub { ... },
                                             method2 => sub { ... }},
                                            @constructor_args);

-- 
Piers Cawley
www.iterative-software.com

Reply via email to