Re: Return Statement Usage
In all situations the end of procedure returns to the calling point.
(Wherever that was.) If you called a global, then it returns to where you
called it from. If you call a local, that procedure would return to the
point from which it was called.
While I do not know the internals of Euphoria, I suspect the return address
is pushed onto a stack that is LIFO. That is, last one on the stack is the
first one off. This would allow the program to always know "..from whence
it came." I also suspect an end of procedure actually executes a return
statement.
The exception is code in an include file that is not within a procedure,
that would run at program start and fall down to whatever other code was
not in a procedure. (ie - your actual main loop somewhere in your program.)
However, you would never be able to "call" that "renegade'" code as it has
no entry point. [ Actually, you COULD call it renegade code, I don't think
any one would care ! ]
At 10:53 PM 6/23/98 -0400, you wrote:
>I have two questions about the return statement.
>
>1. If I have a main program, and I call a global procedure within an
>include file, do I need to put return at the end of the global procedure?
>
>2. In the same set of procedures, in the global procedure, which is in the
>include file, I call a local procedure that is in the same include file.
>Do I need to put return at the end of the local procedure to continue with
>the main procedur?
>
>In general, under what circumstances should one use return at the end of a
>procedure to keep the program from "wandering off"?
>
>--Alan
>
>
Joe Phillips, Assistant Director
Information Technology Services
Texas Wesleyan University 817-531-4284
|
Not Categorized, Please Help
|
|