Re: Try/Catch

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

An index error is a programming error. The programmer needs to know it to fix it.

Not necessarily. In the examples given of crashes, where a loop var is the length of a sequence, and inside the sequence the length is shortened, one could argue for the loop var not being cached. This has not been accepted by the developers of the Eu core.

Spock said...

Why not do this:

1) Don't crash the program but return the element nearest the index value

Because that is wrong. If the sequence is a basket, and the table is memory space, and i ask for the item on the table that is simultaneously the last thing in the basket, the answer isn't the last thing in the basket. The most correct answer (to avoid a crash when you have no try/recover) would be a $null, which the programmer can detect as an obvious error, but that's not acceptable in Euphoria either. The next best would be a "", but that isn't acceptable either.

Spock said...

2) Emit a console message warning of the out-of-bounds index

That's fine for the programmer developing the app, but it's not good for the end user. You may as well just crash with that message. There's several ways asked for to get around crashing. None are acceptable to the powers that be. Forcing the programmer to write bound-checks to each and every loop in each and every program isn't user-friendly, and stomps all over the concept of the compiled code intentionally stripping bounds-checking to speed up the crashing. I cannot help but think that DCuny has the same requests he (we, other people, etc) have made since the days of v2.5. We seek improvements to the core that we cannot add as include files. And i fear his (our, etc) requests will be as useless now as then.

useless

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

Search



Quick Links

User menu

Not signed in.

Misc Menu