Jensen's Device - Criticism

Criticism

Jensen's device relies on call by name, but call by name is subtle and has some problems. Consequently, call by name is not available in most languages. Knuth comments that ALGOL 60 cannot express an increment(n) procedure that increases its argument by one; the call increment(A) does not do the expected action if i is a functional that changes with each access. Knuth says, "The use of 'macro' definition facilities to extend language, instead of relying solely on procedures for this purpose, results in a more satisfactory running program."

Others point out that a call by name procedure that swaps its argument can have subtle problems. An obvious swapping procedure is:

procedure swap(a, b) integer a, b; begin integer temp; temp := a; a := b; b := temp; end;

The procedure does the right thing for many arguments, but the invocation of swap(i,A) is problematic. Using the Copy Rule leads to the assignments:

temp := i; i := A; A := temp;

The problem is the second assignment changes i, so the A in the third assignment probably will not be the same array element as at the start. If on the other hand the procedure were to be coded the other way around (with b being saved to temp instead of a) then the desired action would result, unless it were invoked as swap(A,i)

Read more about this topic:  Jensen's Device

Famous quotes containing the word criticism:

    “Nothing would improve newspaper criticism so much as the knowledge that it was to be read by men too hardy to acquiesce in the authoritative statement of the reviewer.”
    —Richard Holt Hutton (1826–1897)

    “I, with other Americans, have perhaps unduly resented the stream of criticism of American life ... more particularly have I resented the sneers at Main Street. For I have known that in the cottages that lay behind the street rested the strength of our national character.”
    —Herbert Hoover (1874–1964)

    “Cubism had been an analysis of the object and an attempt to put it before us in its totality; both as analysis and as synthesis, it was a criticism of appearance. Surrealism transmuted the object, and suddenly a canvas became an apparition: a new figuration, a real transfiguration.”
    —Octavio Paz (b. 1914)