Continuations in place of exceptions

Assignment Help Basic Computer Science
Reference no: EM13963490

Continuations

In addition to continuations that represent the "normal" continued execution of a program, we can use continuations in place of exceptions. For example, consider the following function f that raises an exception when the argument x is too small:

exception Too Small;

fun f(x) = if x<> then raise Too Small else x/2; (1 + f(y)) handle Too Small => 0;

If we use continuations, then f could be written as afunction with two extra arguments, one for normal exit and the other for "exceptional exit," to be called if the argument is too small:

fun f(x, k normal, k exn) = if x normal(x/2); f(y, (fn z => 1+z), (fn () => 0));

(a) Explain why the ?nal expressions in each program fragment will have the same value for any value of y.

(b) Why would tail call optimization be helpful when we use the second style of programming instead of exceptions?

Reference no: EM13963490

Questions Cloud

What are the capacity implications of the marketing campaign : Suppose that AlwaysRain Irrigation's marketing department will undertake an intense ad campaign for the bronze sprinklers, which are more expensive but also more durable than the plastic ones. What are the capacity implications of the marketing cam..
Which of the following statements is necessarily true : If the temperature of the contents is increased by 10 C degrees, the reading on the Kelvin thermometer should increase by 273 K
What is covalent bonding : What is covalent bonding? why is it different from ionic bonds?
Calculate the first order energy shifts for the ground : Consider a particle in the one dimensional infinite square well potential with width L. The perturbation potential W(x) = b sin(xpi/L) is added to the bottom of the infinite well. Calculate the first order energy shifts for the ground and first e..
Continuations in place of exceptions : In addition to continuations that represent the "normal" continued execution of a program, we can use continuations in place of exceptions. For example, consider the following function f that raises an exception when the argument x is too small:
Control flow and memory management : An exception aborts part of a computation and transfers control to a handler that was established at some earlier point in the computation.
The reaction involved in the purification of nickel : The reaction involved in the purification of nickel is given below. Ni(s) + x CO(g) → Ni(CO)x(g)
Discuss the innovation involved in product development : Choose a product that they are interested in or provides the required information to discuss the innovation involved in its development - What aspect of the technology influenced the development and the products
Ealuation order and exceptions : Suppose we add an exception mechanism similar to the one used in ML to pure Lisp. Pure Lisp has the property that if every evaluation order for expression e terminates, then e has the same value under every evaluation order. Does pure Lisp with ex..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Perform the binary multiplication operations

Convert the hexadecimal number FE95 to decimal and the decimal number 98694 to hexadecimal. Be sure to show all the steps and perform the subsequent binary multiplication operations. Use as many bits as necessary to represent the result.

  Write two distinct fuction prototypes for a function

Write two DISTINCT fuction prototypes for a function that accepts three values and return three values calculated within a function to the calling function.

  What is e-waste

1. What is e-waste? What is so dangerous about e-waste? Many well-meaning individuals thought that recycling was the answer to the e-waste problem. But why hasn't e-waste recycling yielded the results hoped for?

  Which resumes are chosen for further scrutiny

Often a candidate's suitability for a particular job application is determined by the keywords identified by the software used for the purpose of screening.

  Paper is a proposal for leonard cooper charter school

Paper is a proposal for Leonard Cooper Charter School for improving their network. The stakeholders of the system are facing a number of problems, especially since a new addition to the building was added. This proposal addresses each of the stakehol..

  Calculate the overall speedup of a system

Calculate the overall speedup of a system that spends 65% of its time on I/O with a disk upgrade that provides for 50% greater throughput.

  Analyse a packet capture dump file

This assignment question requires that you analyse a packet capture dump file and provide comments explaining each packet. See assignment 1 page of the course website. This pcap file contains a SMTP transaction between a client and server. Your ..

  Discuss the pros and cons

An organization has a number of tools available when determining how best to address performance issues on their network. The organization can use subnetting or they can use segmentation.

  Why is the formulation of the rto and rpo

Why is the formulation of the RTO and RPO a trade-off process?

  Determine which cpu of the two is faster and why

From the first e-Activity, identify the following CPUs: 1) the CPU that resides on a computer that you own or a computer that you would consider purchasing, and 2) the CPU of one (1) other computer. Compare the instruction sets and clock rates of eac..

  Design hardware-software driver processor-peripheral device

Design the hardware and software driver that will implement a byte-wide data transfer from your processor to a peripheral device.

  Solve problem and categorize it by using big-theta notation

Sometimes slight change in problem can significantly modify form of its solution. For instance, determine simple algorithm for solving following problem and categorize it using big-theta notation.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd