Saturday, 6 January 2018
1. What is the different between a language with exception handling and without exception handling? 2. Define exception, exception handler, raising an exception, disabling an exception, continuation, finalization, and built-in exception.
3. What are the alternatives of exception handling?
4. What are the advantages of having support for exception handling built-in to a language?
5. What is tail recursion?
6. What are the differences between functional and imperative languages?
7. What is the basic concept of declarative semantics?
8. Explain about the rule statements.
9. What are the differences between depth-first search and breadth-first search?
10. Explain the negation problem with Prolog. Why this is a limitation?
And my answers are:
1. In a language with exception handling
- Programs are allowed to trap some exceptions, thereby providing the possibility of fixing the problem and continuing.
In a language without exception handling
- When an exception occurs, control goes to the operating system, where a message is displayed and the program is terminated.
2. - Exception : any unusual event, erroneous or not, that is detectable by either hardware or software and that may require special processing.
– Exception handler : a code unit which processes an exception.
– Raising an exception : When a event associated with an exception occurs.
– Disabling an exception : Ignoring a certain hardware-detectable exceptions.
– Continuation : Control transfer to somewhere in the program outside of the handler code or program might terminate .
– Finalization : ability to complete some computation regardless of how subprogram execution terminates.
– Built-in exception : Exception that is not made by the user, but rather comes as default.
3. Alternatives:
– Send an auxiliary parameter or use the return value to indicate the return status of a subprogram.
– Pass a label parameter to all subprograms (error return is to the passed label).
– Pass an exception handling subprogram to all subprograms.
4. - Error detection code is tedious to write and it clutters the program.
- Exception handling encourages programmers to consider many different possible errors.
- Exception propagation allows a high level of reuse of exception handling code.
5. Tail recursive is a special kind of recursion where the recursive call is the very last thing in the function
6. •Imperative Languages:
–Efficient execution
–Complex semantics
–Complex syntax
–Concurrency is programmer designed
•Functional Languages:
–Simple semantics
–Simple syntax
–Less efficient execution
–Programs can automatically be made concurrent
7. The basic concept of declarative semantics is there is a simple way to determine the meaning of each statement, and it does not depend on how the statement might be used to solve a problem.
8. Rule statements are used for the hypotheses and headed Horn clause
•Right side: antecedent (if part)
–May be single term or conjunction
•Left side: consequent (then part)
–Must be single term
9. – Depth-first search: find a complete proof for the first subgoal before working on others
– Breadth-first search: work on all subgoals in parallel
10. The negation problem: Anything not stated in the database is assumed to be false.
Intrinsic limitations: It is easy to state a sort process in logic, but difficult to actually do—it doesn’t know how to sort.
No comments:
Post a Comment