Better language function than exception handling in C ++?

(not sure if this is just a C ++ thing)

Exception handling is difficult to learn in C ++ and, of course, is not an ideal solution, but in most cases (except for some specific firmware contexts) this is by far the best solution that we currently have for exception handling .

What about the future?

Are there other well-known error handling methods that are not implemented in most languages ​​or are only academic studies?

Put another way: are there (presumably) better known (uncomfortable in order) ways to handle errors in programming languages?

+5
source share
5 answers

, , errno . , , , . . , , . , . Java , , , , . , catch(...){/* do nothing*/} ( ++ parlence) , , .

, , (, Scala Either, Option , ). , , , , . ( , Haskell Scala.) , , , .

, , - . :

  • , , , . ( )
  • , , , , , . ( , )
  • langauge, , . (Unchecked Exceptions, Return Codes)
  • 2 3, , , , . ( , )

, 1.

+10

, , , :

1) ( C). , .

2) , " " (). , , . Java "" .

3) "" ( IEEE NaNs, ++ ) , . , , , , , .

. (1) , , , . (2) , who-know-where, , , . (3) , , , UB-, ++, .

, : . , , .

" "? . - , , . , POV , POV , (1) (3).

+6

, , - , Erlang , "Let it fail". : "" ( Erlang "" ). , , , , - .

, , , - . ( , Erlang .)

, , , : http://www.erlang.org/download/armstrong_thesis_2003.pdf

+5

Lisp , , .

+1

, , , X Y, Z, , Y,

  • - , Y , X ; Y, X , Z , X .
  • - , Y , Y .
  • - ; , , , X .
  • , .

, -, , , - , , . , isSatisfied , isSatisfied false, wrapped, isSatisfied . , , AcknowledgeException() isSatisfied. , , , AcknowledgeCoruption() , . , .

I'm not sure what the best architecture will be, but providing the means by which exceptions can indicate to what extent the state of the system is corrupt or intact will be of great importance in alleviating problems with existing architectures.

0
source

All Articles