Re: Short Circuiting + Return in procedures

new topic     » topic index » view thread      » older message » newer message

-----Original Message-----
De: Lmailles at AOL.COM <Lmailles at AOL.COM>
Para: EUPHORIA at cwisserver1.mcs.muohio.edu
<EUPHORIA at cwisserver1.mcs.muohio.edu>
Fecha: jueves 25 de junio de 1998 14:14
Asunto: Re: Short Circuiting + Return in procedures


>Jiri wrote that you can and always will be able to use return to escape
from
>procedures. This is funny because I recently got clobbered by the
interpreter
>for trying to "exit" from a procedure (Yes, I guess I learnt it from
[excuse
>my language] QBasic). However, we have
>
>"exit"
>from loops
>"return"
>from rountines and
>"abort"
>from main routine.
>
>Is this not an unnecessary complication ? Would it hurt anyone to allow
"exit"
>from a procedure Rob ? I think that having "return x" in a procedure would
be
>extremely confusing for a newbie and hints of other inferior languages
which
>allow you to do naughty things like not returning values from functions.


You can use abort() from anywhere in your source. I usually do it. Example:

constant error =    {"Usage: me.exe <file_name>\n",
                                 "Error opening file\n"
                                }
integer fn

function open_file(sequence arg)
    if length(arg) < 3 or length(arg) > 3 then
        puts(1,error[1])
        abort(-1)
    else
        fn = open(arg[3],"rb")
        if fn = -1 then
            puts(1,error[2])
            abort(-1)
        end if
    end if
end function

fn = open_line(command_line())
-- Rest of code ....

Regards,
    Daniel   Berstein
    daber at pair.com

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu