Re: exception handler

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

irv mullins wrote:

> Anyway, as has been mentioned before, the type() routine could be 
> extended in such a way as to allow handling many errors, simply by 
> returning to the top of a program block marked by a 'catch' or 
> 'try' keyword.
> 
> }}}
<eucode>
>  type file(object x)
>    if x =-1 then 
>       msgbox("Cannot open file")
>       return FALSE
>    else return TRUE
>  end type
> 
>  file fn
>  object fname
> 
>  try
>    puts(1,"Enter a file name here:")
>    fname = gets(0)
>    fn = open(fname,"r")
>  end try
> </eucode>
{{{


To follow up, I think this could be added without breaking any code.
As it stands, if the type() check fails, the program quits. If it 
succeeds, then the assignment is made and program flow continues.

A new keyword, "try", would patch into type()'s failure routine, 
and cause execution to resume at the top of the "try" loop. 

If there was no "try" in effect, then 
the type() check would act just as it does now, either make a valid 
assignment, or crash. 

Irv

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

Search



Quick Links

User menu

Not signed in.

Misc Menu