Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

goto statement in tcl?

940 views
Skip to first unread message

Max Stevens

unread,
Jul 15, 1996, 3:00:00 AM7/15/96
to

I'm almost afraid to ask, but is there a goto statement in Tcl?
There's nothing in the index of 'Tcl and the Tk Toolkit' by Ousterhout
and I don't have access to any of the manpages for Tcl, so I'm stuck.
Can anyone give me details on the goto statement if one does indeed
exist? How labels work, etc etc.

I'd be very appreciative, thanks,
Max
--
Max Stevens mste...@mprgate.mpr.ca or joms...@uwaterloo.ca
Any man, in the right situation, is capable of murder. But not any man
is capable of being a good camper. So, murder and camping ar not as
similar as you might think.

Jeffrey Hobbs

unread,
Jul 16, 1996, 3:00:00 AM7/16/96
to

In article <4sej5q$e...@viking.mpr.ca>, Max Stevens <mste...@mpr.ca> wrote:
>I'm almost afraid to ask, but is there a goto statement in Tcl?

Nope. And I haven't missed it, although I have used it in C once or
twice... There is probably an equally good way to do whatever you want.

--
Jeffrey Hobbs Office: 541/346-3998
Univ of Oregon CIS GRF email: jho...@cs.uoregon.edu
URL: http://www.cs.uoregon.edu/~jhobbs/

Gerald W. Lester

unread,
Jul 16, 1996, 3:00:00 AM7/16/96
to Max Stevens

Max Stevens wrote:
>
> I'm almost afraid to ask, but is there a goto statement in Tcl?
> There's nothing in the index of 'Tcl and the Tk Toolkit' by Ousterhout
> and I don't have access to any of the manpages for Tcl, so I'm stuck.
> Can anyone give me details on the goto statement if one does indeed
> exist? How labels work, etc etc.

Tcl does not have a goto statement.

An now for a religious opinion, you don't really need one in any
reasonable language.

**********************************************************************
* Gerald W. Lester | Voice: +1 (504)-889-2784 *
* Computerized Processes Unlimited, Inc. | FAX: +1 (504)-889-2799 *
* 4200 S. I-10 Service Rd., Suite 205 | E-Mail: g...@cpu.com *
* Metairie, LA 70001 | WWW: http://www.cpu.com *
* "Consulting System Integrators" *
**********************************************************************

John Haxby

unread,
Jul 17, 1996, 3:00:00 AM7/17/96
to

Jeffrey Hobbs wrote:

>
> In article <4sej5q$e...@viking.mpr.ca>, Max Stevens <mste...@mpr.ca> wrote:
> >I'm almost afraid to ask, but is there a goto statement in Tcl?
>
> Nope. And I haven't missed it, although I have used it in C once or
> twice... There is probably an equally good way to do whatever you want.

It's also worth noting that Tcl has exceptions (of a sort) with "error"
and "return -code ..." for raising them and "catch" for, well, catching
them.

--
John Haxby
These are my opinions, not my employer's.

Larry W. Virden

unread,
Jul 20, 1996, 3:00:00 AM7/20/96
to

And of course, 'reasonable' means high level language, so there's
no need to post all the places in assembler where goto is needed.
--
:s Larry W. Virden INET: lvi...@cas.org
:s <URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
:s Unless explicitly stated to the contrary, nothing in this posting should
:s be construed as representing my employer's opinions.

Michael Salmon

unread,
Jul 24, 1996, 3:00:00 AM7/24/96
to

Gerald W. Lester wrote:

>
> Max Stevens wrote:
> >
> > I'm almost afraid to ask, but is there a goto
> > statement in Tcl?
> > There's nothing in the index of 'Tcl and the Tk
> > Toolkit' by Ousterhout and I don't have access to
> > any of the manpages for Tcl, so I'm stuck.
> > Can anyone give me details on the goto statement if
> > one does indeed exist? How labels work, etc etc.
>
> Tcl does not have a goto statement.
>
> An now for a religious opinion, you don't really need
> one in any reasonable language.

I disagree, all languages that I know of have goto functionality even if
it isn't called goto. In tcl break, continue and return are goto's,
their functionality is admittedly very restricted though. Event based
callbacks could also be considered as goto though I have to admit that
it is a little obscure.

--
© 1995,1996 Michael Salmon
All opinions expressed in this article remain the property of
Michael Salmon. Permission is hereby granted for use in
followup articles, FAQ's and digests.

Henry Spencer

unread,
Jul 26, 1996, 3:00:00 AM7/26/96
to

In article <31F5BEA9...@uab.ericsson.se> Michael Salmon <Michael...@uab.ericsson.se> writes:
>> An now for a religious opinion, you don't really need
>> one in any reasonable language.
>
>I disagree, all languages that I know of have goto functionality even if
>it isn't called goto. In tcl break, continue and return are goto's,
>their functionality is admittedly very restricted though...

All control structures are just goto in disguise, break/continue/return
no more so than if and while. The restrictions on functionality are not
incidental; they are the important part.

Break/continue/return are odd only if you belong to the Single Entry
Single Exit sect, which claims that all control structures should have
one entry point (fairly uncontroversial) and one exit point (highly
debatable). While there is something to be learned from them, the SESE
fanatics take the basic principle much too far, and the result of strict
adherence to their beliefs tends to be complicated, deeply-nested messes
which can be simplified dramatically with a few returns.
--
...the truly fundamental discoveries seldom | Henry Spencer
occur where we have decided to look. --B. Forman | he...@zoo.toronto.edu

Robert Withrow

unread,
Jul 30, 1996, 3:00:00 AM7/30/96
to

> Gerald W. Lester wrote:
> >
> > Max Stevens wrote:
> > An now for a religious opinion, you don't really need
> > one in any reasonable language.

Well, suppose I want to translate some other scripting
language into Tcl. Suppose that other language has
a GOTO statement. How do I convert arbitrary GOTO statements
into Tcl?

[I *know* of several ways to do it myself, but none of them are
nearly as good as translating GOTOs to GOTOS]

-----------------------------------------------------------------------------
Robert Withrow, Tel: +1 617 592 8935, Net: wi...@rwwa.COM

Gerald W. Lester

unread,
Aug 2, 1996, 3:00:00 AM8/2/96
to Robert Withrow

Robert Withrow wrote:
> Well, suppose I want to translate some other scripting
> language into Tcl. Suppose that other language has
> a GOTO statement. How do I convert arbitrary GOTO statements
> into Tcl?
>
> [I *know* of several ways to do it myself, but none of them are
> nearly as good as translating GOTOs to GOTOS]

You need to restructure the code.

0 new messages