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:

    The aim of all commentary on art now should be to make works of art—and, by analogy, our own experience—more, rather than less, real to us. The function of criticism should be to show how it is what it is, even that it is what it is, rather than to show what it means.
    Susan Sontag (b. 1933)

    ...I wasn’t at all prepared for the avalanche of criticism that overwhelmed me. You would have thought I had murdered someone, and perhaps I had, but only to give her successor a chance to live. It was a very sad business indeed to be made to feel that my success depended solely, or at least in large part, on a head of hair.
    Mary Pickford (1893–1979)

    Good criticism is very rare and always precious.
    Ralph Waldo Emerson (1803–1882)