Breaking out of nested subroutine?

M

Michele Dondi

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


As I've said before, I've never seen it used and I've never used it,
so I didn't know that it still existed. If you structure your programs
appropriately, there will be no need for goto statements. That's what "sub"
is for.

I'm not contending this, nay: I *do* agree with you. Though perl
indeed has a C<goto>. Hence my cmt, period.

More precisely it is true that perl has some flavours of C<goto> in
disguise that blend nicely in the syntax of the language, but a "true"
C<goto> disregarding matters of wether it is considered harmful or
not, is first of all aesthetically unpleasant.

FWIW I did know it existed but have never felt the need of using it
but in one case in which it was the lightest solution to provide some
code with an "extra feature" it had not been thought for in the first
place. Can't even remember what it was about, but remember full well
that I did insert that line half-heartedly and almost feeling guilty!
;-)

Also, as I wrote in another post in this thread there's also a special
form of C<goto> that is useful in certain situations, especially in OO
programming.


Michele
--
It's because the universe was programmed in C++.
No, no, it was programmed in Forth. See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"
 
S

Sam Holden

I've no problem writing (in C):

__close:
if (close (fd) == -1) {
if (errno == EINTR) {
goto __close;
}
perror ("close");
exit (1);
}


IMO, that's cleaner than introducing some extra variable and an extra loop.

while (close (fd) == -1) {
if (errno != EINTR) {
perror ("close");
exit (1);
}
}

Of course the if body could also be used with the goto replaced with
continue. The while loop, to me anyway, expressed what I'm trying to
do more clearly - keep trying to close fd if it fails temporarily.
But as always TIMTOWTDI.

I do use gotos in other situations though, the most obvious example
I can think of being when implementing a state machine.
 
5

510046470588-0001

Michele Dondi said:
More precisely it is true that perl has some flavours of C<goto> in
disguise that blend nicely in the syntax of the language, but a "true"
C<goto> disregarding matters of wether it is considered harmful or
not, is first of all aesthetically unpleasant.

I couldn't care any less what coding fascists consider as unpleasant.


Klaus Schilling
 
M

Michele Dondi

It's not the same thing. The "C" equivalent of "next" is "continue",
equivalent of "last" is "break", while C doesn't have an equivalent of
"redo". If the command exists, you are welcome to use it, but I want to be
the one who would maintain your programs, if you make an extensive use of
the "goto" command. Modular programming languages are usually accompanied
by certain kind of aesthetics which regards the use of "goto" statement as
"ugly". This is not a liberty issue, this is aesthetics. It's exactly the
same thing as putting a bra on the goddess of justice, or putting a
loincloth on a replica of Michelangelo's "David": doable, but silly.

I think that there's some misunderstanding going on here. I think we
all agree at least to a high degree with all these points. All that
Abigail was saying, wittily as usual, is that C<redo>, C<next> and
C<last> are sorts of goto's (albeit aesthetically more acceptable, *I*
say) and that indeed they are quite useful in Perl.


Michele
 
G

Greg Bacon

: [...]
: BTW, I've no doubt that Mr. Dijkstra would have the same dim opinion
: about Perl as a language as he had for 'goto' as a statement.

I'm sure you're right, but I'd be interested in seeing more about why
you think so.

Greg
 
M

Michele Dondi

: BTW, I've no doubt that Mr. Dijkstra would have the same dim opinion
: about Perl as a language as he had for 'goto' as a statement.

I'm sure you're right, but I'd be interested in seeing more about why
you think so.

Just to name one, have you noticed all those funny predefined,
full-of-side-effects (and "massive" ones too!) variables? ;-)


Michele
 
M

Michele Dondi

I couldn't care any less what coding fascists consider as unpleasant.
^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^

Idiot! Don't abuse words you don't have the slightest idea what they
mean. Were you aware of what you wrote, you should feel as deeply
humiliated by it as an arrogant beast like you can be.

There's hardly nothing I hate more than fascism, so don't call me
fascist. Do you know what fascism really is? Ignorance and arrogance,
mostly. Two "virtues" that you seem to possess in a highly
concentrated form...

For one thing one of fascists' mottos used to be (and still is, for
those motherfuckers who still are proud of calling themselves
fascists) "me ne frego", i.e. "I don't care", just as you "don't
care", disgusting dumbass: YOU ARE FASCIST!

Fascists do NOT care, since they are both ignorant and arrogant enough
to elect themselves to some inexistent title that allows them to
reject any other one's opinion. People, as opposed to fascists (that I
do not even consider "people" at all effects) DO care, my non-friend.

So I could have ignored your post and killfiled you, but I can't help
trying to ask you what in my words gave you the right to comment them
giving me *that* name. I was not trying to steal one's freedom to use
any construnct, just expressing a personal, subjective opinion, and
one indeed that is well subjective, but also widely shared on an
objective level and on reasonable basis.

Be ashamed of yourself: "people" are willing to learn. Fascists refuse
to. Go **** yourself.

And no, do not complain for gratuitous insults, for (i) they're not
gratuitous, as nothing is as insulting as what you wrote in the first
place, (ii) you insulted yourself along with me.


Michele
--
Liberta' va cercando, ch'e' si' cara,
Come sa chi per lei vita rifiuta.
[Dante Alighieri, Purg. I, 71-72]

I am my own country - United States Confederate of Me!
[Pennywise, "My own country"]
 
R

Rich Grise

Abigail said:
Mladen Gogala ([email protected]) wrote on MMMCMLXXXVIII September
MCMXCIII in <URL:** On Sat, 31 Jul 2004 23:21:47 +0000, Abigail wrote:
**
** > Well, I find 'goto' in C programs quite handy. In Perl too, except I
** > usually spell 'goto' as 'redo', 'next' or 'last'.
**
** It's not the same thing. The "C" equivalent of "next" is "continue",
** equivalent of "last" is "break", while C doesn't have an equivalent of
** "redo".

I never claimed otherwise. I use 'goto' in C programs. I use 'next',
'last', and 'redo' in Perl programs. That's what I said. How you turn that
into me claiming that C has 'next', 'last', or 'redo', I don't know.

Well, you did say this:
<quote from a couple of posts ago>
Well, I find 'goto' in C programs quite handy. In Perl too, except I
usually spell 'goto' as 'redo', 'next' or 'last'.
[extraneous snipe snipped]
Abigail
</quote>

And it sounds like you're cavalierly claiming that C's continue; and
break; statements are functionally equivalent to a goto, but they're
not.

Hope This Helps!
Rich
 
D

David Combs

Greg Bacon ([email protected]) wrote on MMMCMLXXXIX September MCMXCIII in
}}
}} : [...]
}} : BTW, I've no doubt that Mr. Dijkstra would have the same dim opinion
}} : about Perl as a language as he had for 'goto' as a statement.
}}
}} I'm sure you're right, but I'd be interested in seeing more about why
}} you think so.


That's mostly based on memories when I was still doing research at a
university where a lot of the members of the staff were Dijkstra adepts,

Cornell? (David Gries et al were often part of his entourage,
and I imagine that they also worshiped him as a god.)
and his (handwritten (!)) notes were faxed, copied and distributed among
staff members, who were supposed to study them as if it was a gospel. I
still think that there was a shrine dedicated to him in the small room
that was always closed.

Years (eons) ago I attended two years of cs summer-schools
at UC-Santa-Cruz,
4 weeks long, I think it was, and (just about ) *all* the "biggies"
were there as guest lecturers or ran entire courses.

E.D. was there, complete with entire entourage from both
Amsterdam and Cornell (via Gries).

Dijkstra was of course an extremely smart guy, a genius, even,
and wanted everyone, it seemed, to know it.

Once I recall him, before class, elaborating on how he rarely
made mistakes, and as an example told us how he developed
as a letter-writer.

He decided that he was spending far too much time in rewriting,
and in correcting eg spelling errors, so he decided to
switch to indelible ink. Any mistake, and he had to
rewrite the whole letter. Soon, he said, he learned
to make *no* errors, *ever*, in letters he wrote --
saying that in much the same voice and with the same
body stance that maybe De Gaulle would have done.

(You get idea?)

Anyway, he was well known for his I-am-a-genius
perceived-by-us attitude.

Now, he had an unusual style of script he used,
quite recognizable, and apparently unique. Also
well known and commented upon.

Anyway, once (also years ago) I was visiting someone
(maybe hanging-around better describes it), and
on the wall in someone's office, or maybe it was
on his door?, was a page of "Dijkstra-writing"
that was not only in his unique handwriting, but
in his also-unique way of speaking (often, about
himself).

It was a parody, but beautiful, really nailed him.

What was interesting to me was how they got the
handwriting. Turns out, they had designed a
new postscript font, "Dijkstra", and then written
this parody using it.

Maybe it's still around someone, floating on the net...

Pretty funny stuff!

David
 
D

David Combs

^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^

Idiot! Don't abuse words you don't have the slightest idea what they
mean. Were you aware of what you wrote, you should feel as deeply
humiliated by it as an arrogant beast like you can be.

There's hardly nothing I hate more than fascism, so don't call me
fascist. Do you know what fascism really is? Ignorance and arrogance,
mostly. Two "virtues" that you seem to possess in a highly
concentrated form...

For one thing one of fascists' mottos used to be (and still is, for
those motherfuckers who still are proud of calling themselves
fascists) "me ne frego", i.e. "I don't care", just as you "don't
care", disgusting dumbass: YOU ARE FASCIST!

Fascists do NOT care, since they are both ignorant and arrogant enough
to elect themselves ...

Oh, I get it -- you're talking about American politics!

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top