[comp.lang.pascal] Gotos are okay, but what about COME-FROM's??

phys169@csc.canterbury.ac.nz (01/25/91)

This is all getting very silly. Reminds me of the COME-FROM that was suggested
after an even sillier discussion of goto's. Anyone remember that?? Since this
topic never seems to die, for those wishing to skip boring postings on the
subject, here's by method:

If the person...                 Then...
Hates GOTO but likes EXIT/BREAK  Ignore the idiot, he can't see the similarity.
Hates GOTO (no word of EXIT)     Probably an even greater idiot, who hasn't
                                 even heard of EXIT or BREAK
Hates GOTO and EXIT and BREAK    Probably never written a real program. Ignore!
Likes GOTO but not EXIT/BREAK    Great idiot who only knows BASIC, listen to
                                 them very carefully - might be your boss!

(Purely humerous; no similarity to persons living or dead, etc) 
Seriously, making hard and fast generalizations about people like this is as
bad as generalisations about programs with GOTO's. In some classes of problem,
a goto is very good, and simplifies the program (often in error conditions or
process control applications). But most often, a goto simply indicates sloppy
thinking. 

maine@elxsi.dfrf.nasa.gov (Richard Maine) (01/25/91)

On 25 Jan 91 05:15:17 GMT, phys169@csc.canterbury.ac.nz said:

phys169> This is all getting very silly. Reminds me of the COME-FROM
phys169> that was suggested after an even sillier discussion of
phys169> goto's. Anyone remember that??

Would you believe that I've used a Fortran compiler that actually
implemented the comefrom statement?  It was not a documented
feature, just a bit of insider humor on the part of the compiler
writers.  On a hint, I tried it out and it really worked.
(No, I was not silly enough to use it on "real" programs, though
for a while I kept a little sample around to amuse people with).

I think it disappeared soon after a customer submitted a bug
report relating to it!  If I recall, the bug report had something
to do with the optimizer not recognizing loops implemented with
comefroms, making them run slower than loops done with gotos or
do statements.  (I may not have this part 100% right).

The machine was an Elxsi 6400, which we still have (yes its the
one my email address below shows).  I forget the version of the
compiler, but it was probably about 3-4 years ago.

--
Rich Maine
maine@elxsi.dfrf.nasa.gov

elmo@troi.cc.rochester.edu (Eric Cabot) (01/26/91)

While we are on the subject of Exit, I really miss the form of
Exit used by UCSD pascal-whereby you could exit out of several
nested procedures.  Although I happily switched to Turbo
years ago, the UCSD version  is, IMHO, far more general and useful.

Here's an example of how it worked:

Program non_turbo_exit;

procedure a;
   procedure b;
          procedure c;
          begin  (*c*)
            exit(a);
            writeln(' very') (*never executed*)
          end; (*c*)

     begin (*b*)
          c;
          writeln('cold ') (*never executed*) 
     end; (*b*)
begin (*a*)
  b;
  writeln('cruel') (*never executed*)
end; (*a*)

begin (*main*)
   writeln('hello');
   a;
   writeln('world')
end. (*main*)
 
Notice that the statement exit(a) takes the execution back to
the point the a was called in main.

-Just My $0.02 worth

--
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Eric Cabot                              |    elmo@uhura.cc.rochester.edu
      "insert your face here"           |    elmo@uordbv.bitnet
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

maman@uranie.inria.fr (Nathan Maman) (01/29/91)

	I don't know exactly how these COMEFROM's worked, but perhaps
	they could be used in Exceptions|Errors|Signals treatment(s).

	Example:

	Sub s1
	    statements
	    return
	  entry-point s1_some_signal
	    treatment
	    you should be able here to
		a) return to calculation in s1
		b) return to calling sub
		c) exit from program with some message
	end s1

	Sub signal_handler
	    if COME-FROM s1
	    then go to s1_some_signal
	    end if
	    return (or whatever: stop, ...)
	end

	What do you think, am I wrong ?

-- 
				Nat.

+--------------------------------------------------------------------------+
| Address: M. Nathan MAMAN, INRIA Sophia-Antipolis, 06560 Valbonne, FRANCE |
| E-mail: maman@mirsa.inria.fr, Phone: 33-93.65.77.95, FAX: 33-93.65.78.58 |
+--------------------------------------------------------------------------+