Download Analysis and research into errors produced while
Transcript
Anah·sis of' meThods To re.wll·<· <'rrors information. more specifics are given as to the error's nature. e.g. unexpected end or lik. nameclash etc. If you can recognise certain patterns in an error message. e.g. an unexpected end of tile has occurred. then a predefined solution could he on hand to he presented to the programmer. The afore mentioned unique parts of an error message would form the rules of the expert system. An example of one of these rules might he : if "unexpec:.ed end of file" is part of the error message, appropriate solution for unexpected end of file ...... then offer The solution that would be presented to the programmer would only form part of the output. They would also be presented with most of the information that the Miranda compiler would have originally output. although in a different form. The general format of the output would be: A <error t~~e> has been detected on line <line number> Problem : ~he error itself Diagnosis <Solution or hints on how to solve the error> 4.2.1 Function definition errors Section 3.4.1 highlighted the problem that exists with Function definition errors. in that you can never be sure that the programmer has implemented a function correctly and specified it incorrectly or vice versa. All that you can do here is offer some hint as to what the programmer may wish to do to try and get rid of the error, but never a firm solution. For this reason, Function definition errors can be considered to be resolvable by inspection. 4.3 Formal parameters and return types When a Type error occurs in a function, what would constitute a more meaningful error message than already exists? Let us return to the simple type error: type error in definition of wrongl (line 4 of "errors.m") cannot unify bool with num which is generated when trying to compile the code > wrongl x = x, if x < 3 = True, otherwise > cannot unify num with bool may seem easy enough to understand, and looking at the code, you can see that the return types are different and have to be altered. However. the 'new' functional programmer is unlikely to be familiar with the intricacies of unification and may need some more information on the error that has occurred. General information about how functions have to return the same types etc. can be provided regardless of the content of the error message, but to make the information that is provided comprehensive. some specific information about the function that is in error would need to be given. 23