On Saturday, August 31, 2002, at 05:28 , Gfoo wrote:

> A question regarding closures used as function templates:
[..]

I think you present a cogent argument - but, perchance
you might want to think about an OO style solution -
although I do not wish to sound too felixian in this.

cf:
http://www.wetware.com/drieux/pbl/perlTrick/OO/SG3/

You will find in there two modules - one a boring and
dull GenOO.pm - that is really - well a way to hide
that weird AUTOLOAD - but with it I don't have to worry
about things like creating accessor's in sub classes.

Hence I can create the Food.pm sub_class with essentially
two methods - a new and init. hence I can get to that
do_food.plx sequence really quicky and offer you:

        my $dog = Food->new( young => 'bones', senior =>'meat');
        my $cat = Food->new( young => 'fish');
        
        print "young dogs should eat: ",$dog->young() , "\n";
        print "young cats should eat: ", $cat->young() , "\n";

        if ( my $old_cat_food = $cat->senior() ) {
                print "old cats eat: $old_cat_food \n";
        } else {
                print "there are no old cats...\n - We are all just cool\n";
        }

your mileage may vary... void where prohibited...

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to