Message from discussion
Perl goto (was: static variable problem)
Received: by 10.68.213.103 with SMTP id nr7mr10873330pbc.7.1352935760715;
Wed, 14 Nov 2012 15:29:20 -0800 (PST)
Received: by 10.50.34.167 with SMTP id a7mr611807igj.5.1352935760676; Wed, 14
Nov 2012 15:29:20 -0800 (PST)
Path: s9ni10239pbb.0!nntp.google.com!kr7no15514016pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: comp.lang.perl.misc
Date: Wed, 14 Nov 2012 15:29:20 -0800 (PST)
In-Reply-To: <87obj0pbbx.fsf_-_@sapphire.mobileactivedefense.com>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=24.143.92.94; posting-account=ISlgcwoAAADwTROnYSMhV8h6Fh3lwvEm
NNTP-Posting-Host: 24.143.92.94
References: <fV45K0OBJxbE-pn2-l0DOsOblSoed@localhost> <3ca96274-d8ae-4d20-9ec4-d643ec5caae9@googlegroups.com>
<87obj0pbbx.fsf_-_@sapphire.mobileactivedefense.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f85691b4-ead5-4978-b23f-8ecc146127a5@googlegroups.com>
Subject: Re: Perl goto (was: static variable problem)
From: "C.DeRykus" <dery...@gmail.com>
Injection-Date: Wed, 14 Nov 2012 23:29:20 +0000
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, November 14, 2012 5:23:49 AM UTC-8, Rainer Weikusat wrote:
> "C.DeRykus" <dery...@gmail.com> writes:
>
>
>
> [...]
>
>
>
> > goto BLOCK;
>
> >
>
> > FOO: foo("Hello World");
>
> > exit;
>
> >
>
> > BLOCK: {
>
> > my $bar = 1;
>
> >
>
> > sub foo
>
> > {
>
> > my $a = shift;
>
> > print "$bar $a\n";
>
> > return;
>
> > }
>
> > goto FOO;
>
> > };
>
>
>
> In contrast to 'other languages', the destination of a Perl goto is
>
> determined at runtime, by 'outward' searching (IIRC, term used by the
>
> Camel book) for a matching label in all currently active lexical
>
> scopes. This implies that, compared to other means for performing flow
>
> control, it is a very expensive operation.
>
>
>
> --------------
>
> use Benchmark;
>
>
>
> timethese(-5,
>
> {
>
> goto => sub {
>
> goto out;
>
>
>
> print "ha!";
>
>
>
> out:
>
> return 3;
>
> },
>
>
>
> return => sub {
>
> return 3;
>
> }});
Thanks, that's interesting. I would have
thought that it'd be much cheaper. Of course,
spaghetti code is super bad anyway for all
the reasons we know about. You gotta have
Clint Eastwood's steely gaze and grit to
follow the crooked trails and dodge bullets
that might ricochet anywhere.
That's why I said "duck".
--
Charles DeRykus