Title: Message
John,
 
    Look up function dispatch tables on perlmonks.com.  It's a pretty good alternative to switch case statements (better than if-else, anyway). 
 
    But as to your question, I don't know if there was any functionality change made.
 
Sam
 
 

Sam Gardner

GTO Application Development

Keefe, Bruyette & Woods, Inc.

212-887-6753



-----Original Message-----
From: John Deighan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 13, 2005 9:55 AM
To: [email protected]
Subject: Re: Change in "goto" behavior

At 08:30 AM 7/13/2005, Hugh Loebner wrote:
Why on earth are you using a goto statement?  They are pernicious.

We have a goto in our code. I hate it, but there just isn't a good "switch" or "case" statement in Perl yet (I think I've heard that it's planned), and the following just isn't efficient enough for us:

if ($op = 'thisop') {
        }
elsif ($op = 'thatop') {
        }
...

There are hundreds of possible values for $op. Anyway, I don't know how many people are aware of it, but the destination of a "goto" can be a variable, e.g.

goto $op;

thisop:
         do_this();
thatop:
         do_that();

Of course, you then have to prevent the fall through from the code for thisop: to the code for thatop:, but that's another matter. (We initially used a "goto FINISH", but I hated that, too. You can use a "break" if you're in a loop.) We use a method that I really don't have time to describe now, but doesn't use a "goto". I hate goto's, but for the example above, it's efficient and much clearer than e.g. setting up a hash of op names and code to handle each op.

On 7/12/05, Dave Ressler <[EMAIL PROTECTED]> wrote:
I have noticed a change in behavior in "goto" statements recently. Whereas a statement like "goto PLACE;" would work fine no matter where "PLACE:" was in my code, I've noticed that scripts that used to work are now failing at the "goto" statement.

 
I can probably work out an example if needed, but the general question is: have any restrictions been put on "goto" recently? What are the real criteria needed to be satisfied for the destination to be successfully found?

 
Thanks,
Dave

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




Scanned for Spam and Viruses.
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
X-NAIMIME-Disclaimer: 1
X-NAIMIME-Modified: 1

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Scanned for Spam and Viruses.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to