Improving Robustness via Disjunctive Statements in Imperative Programming

AbstractTo deal with failures as simply as possible, we propose a new foun-dation for the core (untyped) C, which is based on a new logic calledtasklogicorimperativelogic. Wethenintroduceasequential-disjunctivestatementoftheformS:R. Thisstatementhasthefollowingsemantics:execute S and R sequentially. It is considered a success if at least oneofS,R is asuccess. This statement is usefulfor dealing with inessentialerrorswithoutexplicitlycatchingthem. 1 Introduction Imperative programming is an important modern programming paradigm. Suc-cessful languages in this paradigm includes C and Java. Despite much attrac-tiveness, imperative languages have traditionally lacked fundamental notion ofsuccess/failure for indicating whether a statement can be successfully completedor not. Lacking such a notion, imperative programming relies on nonlogical,awkward devices such as exception handling to deal with failures. One majorproblem with exception handling is that the resulting language becomes com-plicated and not easy to use.To deal with failures as simply as possible, we propose a new foundation forthe core (untyped) C, which is based on a new logic called task logic [1, 2] orimperative logic. The task logic expands the traditional t/f (true/false) so as toinclude T/ F(success/failure). The task logic interprets each statement as T/F,depending on whether it can be successfully completed or not. The prematureexit of a statement due to failures can be problematic. To avoid this, we adopt“all-or-nothing” semantics discussed in [3] to guarantee atomicity. Thus, if afailure occurs in the couse of executing a statement, we assume that the machinerolls back partial updates.We can then extend this “logic-based”C with other useful logical operations.To improve robustness, we introduce a sequential-disjunctive statement of theform S: R. Here, to avoid complications, we assume that Sand Rare indepen-dent of each other, i.e., no variables appear in both S and R. This statementhas the following semantics: execute S and R sequentially. It is considered a1

[1]  Giorgi Japaridze,et al.  Introduction to computability logic , 2003, Ann. Pure Appl. Log..

[2]  Giorgi Japaridze,et al.  Sequential operators in computability logic , 2007, Inf. Comput..

[3]  Christof Fetzer,et al.  Improving Program Correctness with Atomic Exception Handling , 2007, J. Univers. Comput. Sci..

[4]  Peter A. Buhr,et al.  Advanced Exception Handling Mechanisms , 2000, IEEE Trans. Software Eng..

[5]  Gopalan Nadathur,et al.  Uniform Proofs as a Foundation for Logic Programming , 1991, Ann. Pure Appl. Log..