in reply to Duff's Device

From a posting of mine I made in 1998 in one of the Perl groups:
And you can do that in Perl as well: my $n = int (($count + 7) / 8); goto (qw !LABEL0 LABEL1 LABEL2 LABEL3 LABEL4 LABEL5 LABEL6 LABEL7!) [$count % 8]; { LABEL0: print "0\n"; LABEL7: print "7\n"; LABEL6: print "6\n"; LABEL5: print "5\n"; LABEL4: print "4\n"; LABEL3: print "3\n"; LABEL2: print "2\n"; LABEL1: print "1\n"; redo if -- $n > 0; }

It's certainly legal to jump into a bare block, and bare blocks are looping constructs as well.

Abigail

Replies are listed 'Best First'.
Re: Re: Duff's Device
by QM (Parson) on Feb 25, 2004 at 00:54 UTC
    I wanted to play with this (and the other examples) in the debugger. Apparently the debugger has problems with goto jumping into blocks while single stepping. Depending on the variation, I get a Windows error (running inside a "Dos Shell"), or the debugger just exits.

    Here is the version:

    This is perl, v5.8.0 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2002, Larry Wall Binary build 806 provided by ActiveState Corp. http://www.ActiveState. +com Built 00:45:44 Mar 31 2003
    Running normally (no debugger) doesn't have this problem. In the debugger, staying within a block or jumping outside of a block is OK too. [I only tried bare blocks, nothing fancy.]

    Hrmm....

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of