Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
useless_ said...
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.

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

An index error is a programming error. The programmer needs to know it to fix it. Why not do this:

1) Don't crash the program but return the element nearest the index value
2) Emit a console message warning of the out-of-bounds index

Wouldn't matter if it was in a procedure/function etc

Jim could add this to the interpreter in, like, 5 minutes.

Spock

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

Search



Quick Links

User menu

Not signed in.

Misc Menu