[Israel.pm] sub subroutines??

Tal Kelrich tal at musicgenome.com
Mon Oct 30 09:24:28 PST 2006


One could always use anonymous subroutine references, but it gets messy
all in all.


On Mon, 30 Oct 2006 18:00:03 +0200
Yuval Kogman <nothingmuch at woobling.org> wrote:

> Use a class:
> 
> 	package F1;
> 
> 	sub the_sub {
> 		my ( $self, @args ) = @_;
> 
> 		$self->show;
> 
> 		$self->update;
> 	}
> 
> 	sub show {
> 
> 	}
> 
> 	sub update {
> 
> 	}
> 
> The polymorphism has to be resolved somehow-- if you want the
> subroutines named identically, then an object must mediate between
> the different meanings of 'update' and 'show'.
> 
> The reason for this is that there are no lexically scoped
> subroutines. It has been proposed that 'my sub foo { }' be added to
> Perl, but this has not yet been done (see Perl 6 and some hacks on
> the CPAN if you *really* want this)
> 
> On Sun, Oct 29, 2006 at 07:14:36 -0800, rami doqa wrote:
> > hello perl programmers, is there any way to do the
> > following in perl:
> > -------------------------------------
> > sub f1
> > {
> > 	show();  # calls the show on the f2 subroutine but i
> > need to call show of f1?
> > 	update();
> > 	....
> > 	sub show {..f1.}
> > 	sub update{.f1..}
> > }
> > 
> > sub f2
> > {
> > 	show();   # calls the show on the f2 (right)
> > 	update();
> > 	....
> > 	sub show {..f2.}
> > 	sub update{..f2.}
> > }
> > -----------------------------------------------------------
> > and i want to know if this is a good or bad
> > programming style 
> > thanx alot
> > 
> > regards 
> > dakka, rami 
> > 
> > 
> >  
> > ____________________________________________________________________________________
> > Want to start your own business? Learn how on Yahoo! Small Business 
> > (http://smallbusiness.yahoo.com) 
> > 
> > _______________________________________________
> > Perl mailing list
> > Perl at perl.org.il
> > http://perl.org.il/mailman/listinfo/perl
> 


-- 
Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F  CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
----
Leela: I guess you never really outgrow being an eyeball... oddball.
----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20061030/6326b675/attachment.pgp 


More information about the Perl mailing list