On Thu, Sep 22, 2005 at 02:50:13PM +1000, Erik de Castro Lopo wrote:
> One thing thats been bugging me for a while about Perl is the
> lack of a butfirst keyword. This would be *really* useful for
> constructs like:
>
> {
> # Huge chunk of code
> }
> butfirst
> {
> # Second huge chunk of code to be executed
> # before the one above.
> } ;
Don't be silly, of course it does:
----------------------------------------------------------------------
#!/usr/bin/perl -w
(eval{
print "foo\n";
print "baz\n";
}) if (eval{
print "bar\n";
print "bing\n";
print "bong\n";
} and 1 );
----------------------------------------------------------------------
or just define your own syntax:
----------------------------------------------------------------------
#!/usr/bin/perl -w
sub later (&@)
{
@_ = reverse @_;
my $x;
while( $x = shift ) { &$x; }
}
sub butfirst (&@) { @_ }
later
{
print "foo\n";
print "baz\n";
}
butfirst
{
print "bar\n";
print "bing\n";
print "bong\n";
}
butfirst
{
print "zap\n";
print "atooey\n";
}
----------------------------------------------------------------------
All of which I'm sure has been demonstrated elsewhere.
But then we all know that if a programming language can define what
is *really* useful then it might as well just define the actual
program (since at the end of the day, a running program that performs
a task is the only thing that is *really* useful). Once we have such
a programming language then we won't need programmers at all.
In the meantime, I'll settle for perl and make my own calls about
which features I find useful and which I don't.
- Tel
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html