chris@umcp-cs.UUCP (Chris Torek) (08/09/86)
>In article <2785@umcp-cs.UUCP> I wrote: [an example of how a Mesa programmer would probably write `find']: >> find: PROC [ch: CHAR, string: LONG STRING] >> RETURNS [pos: CARDINAL, found: BOOL]; >> BEGIN >> FOR i:CARDINAL in [0..String.Length[string]] DO >> IF string[i] = ch THEN RETURN [i, TRUE]; >> ENDLOOP; >> RETURN [0, FALSE]; >> END; In article <1174@umd5> zben@umd5.umd.edu (Ben Cranston) writes: >I always avoided these nonstandard returns because they make it painful to >drop in debug print statements. I would always slap in WRITELN(MYARGS) at >the top, and WRITELN('Returning from FIND') at the bottom, and wonder why >I never saw the 'Returning from FIND' output... If you are trying to find >an infinite loop this can be really misleading. Ah, but in Mesa, no one ever seems to use debug prints: for there is a very complete debugger that is always accessible. For that matter, if you did wish to wrap `find' with debug print statements, you could simply rename the procedure to `findInternal' and add -- Again, details may be wrong; all the manuals are four miles -- away. find: PROC [ch: CHAR, string: LONG STRING] RETURNS [pos: CARDINAL, found: BOOL]; BEGIN Msg.PutMsg["Enter find"L]; [pos, found] _ internalFind[ch, string];--`_' represents left-arrow Msg.PutMsg["Exit find"L]; RETURN [pos, found]; END; Indeed, this technique works in every language. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu