Re: goto return ?



In article <45676C2D.3060707@xxxxxxxxxxxxxxx>,
mlists@xxxxxxxxxxxxxxx (JupiterHost.Net) wrote:



do_some_stuff_and_return( @stuff ) if $whatever;

# we got this far so keep on moving

The trick is I can't seem to goto() return in
do_some_stuff_and_return(), I'm sure since its so deep down...

Maybe you mean it to be like this:

@stuff = do_stuff_and_return();
where the subroutine contains:
return @an_array;
in it.

Or you can pass a reference like this:

my @stuff = ();
do_stuff_and_return(\@stuff);

and the subroutine would be something like:

sub do_...{
my $ref = shift;
# do stuff
$ref = \@my_array;
# no return statement needed.
}

Bottom line: the subroutine can alter the parameter list, or (better)
return an array.

Boyd
.



Relevant Pages

  • Re: Problem writing code to go to a label after calling a procedure
    ... >>I first tried to create procedures for parts of the program to avoid ... Thanks for the advice J French. ... I know a good program structure avoids many goto ... subroutine, this is somthing I found that Visual Basic can't do. ...
    (comp.lang.basic.visual.misc)
  • Re: Programming languages
    ... pipeline to be flushed. ... Subroutine calls are interruptions of an orderly flow, ... The compiler may even inline the function if it's small. ... the target of a goto, the compiler has to discard all cache and register ...
    (sci.lang)
  • Re: Programming languages
    ... they constitute unpredictable interruptions of what ... Subroutine calls are interruptions of an orderly flow, ... the target of a goto, the compiler has to discard all cache and register ... which requires the pipeline to be flushed. ...
    (sci.lang)
  • Re: Use of subroutines
    ... >>I still maintain that a subroutine is first and foremost a GOTO ... > GOTO transfers control with no provision to return and continue ... > continue execution. ...
    (comp.lang.fortran)
  • Re: Use of subroutines
    ... Go tos are not evil. ... >I still maintain that a subroutine is first and foremost a GOTO ...
    (comp.lang.fortran)