Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
dcuny said...
eukat said...

Choose a soft and graceful fail, and it will do what the filesystem does: extend the sequence and return a {} or a null.

I have asked for this for years

The idea that Euphoria just continues on merrily when it knows there was a logic error seems a fundamentally flawed idea, and I doubt many will accept it.

<snip>

So, for example, you could define what you consider sensible behavior to perform on indexing errors for your code without adversely effecting other people's code.

But even with that, there are still conditions where you would want to throw an exception.

- David

This is why i said "choose". In the case you gave of the string being indexed out of bounds, the programmer should know there is no {} in their string. Getting a {} back indicates an error, but i would assume that in indexing by atom in that string, the programmer is looking at each atom for some reason, and would recognise a {}, and perform code accordingly.

If Eu provided a switch for "fail gracefully" or "crash dead", then you choose. I think it beats the programmer wrapping each and every variable access in bounds-checking code (which slows things down), which the compiled Eu intentionally doesn't do (so as to speed things up). For the example you gave.

useless

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

Search



Quick Links

User menu

Not signed in.

Misc Menu