Value Transforming Style

نویسنده

  • Christian Queinnec
چکیده

A new program transformation is presented that allows to remove control operators related to partial continuations. The basis for the transformation is to adopt an improved representation for continuations that makes frames apparent. Various examples of control operators with or without dynamic extent stress are presented. Scheme IEE91], ooers rst-class continuations with indeenite extent. Pioneered in Lan65, Rey72], continuations proved to be very useful tools allowing to program a wide variety of control features such as coroutines Wan80], engines HF84], escapes HFW84] etc. The call/cc function reiies Wan86] continuations into monadic functions, transfer of control occurs when these functional objects are applied. A transformation called \Continuation Passing Style" (or CPS for short) exists that transforms a program using call/cc into a new semantically equivalent program without call/cc. In this transformation, continuations are transformed again into monadic functions. CPS has been extensively studied, see DL92, SF92] for recent developments. CPS is also a programming style. A function written in CPS-style takes an extra argument known (mis!?)fortunately as the continuation. This continuation represents the nal receiver of the value computed by the function. This extra argument does not need to be a real continuation, an object built by call/cc, but can simply be a value transformer i.e.a regular monadic function without control eeect. Consider for instance the CPS-transformed factorial function: (define (cps-fact n k) (if (= n 1) (k 1) (cps-fact (-n 1) (lambda (r) (k (* n r)))))) One generally invokes this CPS-style cps-fact function as (cps-fact 5 (lambda (x) x)) rather than as (call/cc (lambda (k) (cps-fact 5 k))). This turns out to be psychologically important: people tend to view the k variable of cps-fact as holding a value transformer which is applied on the nal result rather than as an escape to the calling point of cps-fact with the nal value. Partial continuations are a new concept and allow to abstract over control. Several sets of control operators were proposed in FWFD88, DF90, QS91]: they emphasize diierent aspects and have various properties. Unlike regular continuations, partial continuations are real functions that return values: they thus can be composed and resemble more to value transformers. For instance and with the notations of QS91], the following factn function, given a number n, returns a function which will multiply its unique argument by the factorial of n: (define (finalizing-fact n terminator) (if (= n 1) (terminator 1) (* n (finalizing-fact (-n 1) …

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Transforming Disciplinary Traditions; Comment on “Problems and Promises of Health Technologies: The Role of Early Health Economic Modeling”

Grutters et al show that economic assessments can inform the development of new health technologies at an early stage. This is an important contribution to health services and policy research, which implies a “shift away” from the more traditional forms of academic health economic modeling. Because transforming established disciplinary traditions is both valuable and de...

متن کامل

Transforming Geocentric Cartesian Coordinates to Geodetic Coordinates by a New Initial Value Calculation Paradigm

Transforming geocentric Cartesian coordinates (X, Y, Z) to geodetic curvilinear coordinates (φ, λ, h) on a biaxial ellipsoid is one of the problems used in satellite positioning, coordinates conversion between reference systems, astronomy and geodetic calculations. For this purpose, various methods including Closed-form, Vector method and Fixed-point method have been developed. In this paper, a...

متن کامل

Back to Direct Style

This paper describes the transformation of I-terms from continuation-passing style (CPS) to direct style. This transformation is the left inverse of Plotkin’s left-to-right call-by-value CPS encoding for the pure I-calculus. Not all I-terms are CPS terms, and not all CPS terms encode a left-to-right call-byvalue evaluation. These CPS terms are characterized here; they can be mapped back to dire...

متن کامل

Three Steps for the CPS Transformation

Transforming a λ-term into continuation-passing style (CPS) might seem mystical at first, but in fact it can be characterized by three separate aspects: • The values of all intermediate applications are given a name. • The evaluation of these applications is sequentialized based on a traversal of their syntax tree. This traversal mimics the reduction strategy. • The resulting term is equipped w...

متن کامل

Effect of Transforming Growth Factor-β (TGF-β) on proliferation of gastric epithelial cells in culture

Objective: Helicobacter pylori has a well-established role in the development of gastric cancer. In vitro studies reveal increased proliferation of the gastric mucosa in the presence of H. pylori infection. It has been also shown that production of some cytokines, such as interleukin-1 beta (IL-1b) is in...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1992