Re: Try/Catch

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

petelomax,

Please explain me briefly, using simple words, why exception handling became norm in computer programming.

You see, logically it seems to be such a backward technique for programming. Many "exceptions", such as "Drive-not-Ready" are just a Boolean variable that indicates the status of specific hardware; Why then, and how come, this simple Boolean variable turned into a "football game", with Throw, Catch, etc?

If the operating system treats "exceptions" as a simple Boolean flag - why my program must treat it as a football game with many players?

I'm asking you this question because you must know much better then me. It might be a stupid question from others point of view, but I really want a logical and short answer, with practical example(s) - if you don't mind.

I could not imagine an "exception" in industrial PLC programming. A digital sensor can tell only TRUE or FALSE - your program does what ever it wants with this info. An analog sensor can only supply a value within a known range, and again, your program will take it or leave it.
In PLC, "exception" can mean only one thing: The whole factory is on fire, and it's time to call the fire department; i.e. it's not something that the PLC has to deal with.

Why then "some sensors", i.e. some routines, must trigger "exception" in computer programming(?!?) what is the logical reason for this?

Thank you in advance.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu