Re: Try/Catch

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

.. and hopefully never will. In the meantime it remains a programming error.

useless_ said...
Spock said...

Why not do this:

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

Because that is wrong..

Yes, it is wrong but at least the program don't crash. What is right? Unless the programmer specifies the treatment in such a scenario there's no way the computer can figure it out. And if the programmer specifies it then he should really have corrected the bug that lead to that scenario in the first place.

useless_ said...

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.

If the programmer can detect a $null, he should really be detecting the index error instead since that is where the bug is. What place then for $null ?

useless_ said...
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.

Not so. The warning could advise the user that a serious error has occurred and suggest that they might save any data and shut the program down. A more sophisticated approach could also record a log file to be sent to the programmer.

useless_ said...

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..

You overstate the problem. The vast majority of loops in a program will be plain enough to not require any such checks.

useless_ said...

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.

You sure got that right .. Muahahaha!

If you're up for it you could always write your own core. That's what I'd like to do .. one day.


Spock

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

Search



Quick Links

User menu

Not signed in.

Misc Menu