Jensen's Device

Jensen's Device

Jensen's Device is a computer programming technique devised by Danish computer scientist Jørn Jensen after studying the ALGOL 60 Report.Fact|date=February 2007

The following program was proposed to illustrate the technique. It computes the 100th harmonic number by the formula H_{100}=sum_{i=1}^{100} frac{1}{i}:

begin integer i; real procedure sum (i, lo, hi, term); value lo, hi; integer i, lo, hi; real term; comment term is passed by-name, and so is i; begin real temp; temp := 0; for i := lo step 1 until hi do temp := temp + term; sum := temp end; comment note the correspondence between the mathematical notation and the call to sum; print (sum (i, 1, 100, 1/i)) end

The above exploits call by name to produce the correct answer (5.187...). It depends on the assumption that an expression passed as an actual parameter to a procedure would be re-evaluated every time the corresponding formal parameter's value was required. If the last parameter to sum had been passed by value, and assuming the initial value of i were 1, the result would have been 100 × 1/1 = 100.

Moreover, the "first" parameter to sum,representing the "bound" variable of the summation,must also be passed by name, otherwise it would not be possibleto compute the values to be added.(On the other hand, the global variable does not have to use the same identifier,in this case i, as the formal parameter.)

Donald Knuth later proposed the Man or Boy Test as a more rigorous exercise.


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Jørn Jensen — Jørn Jensen, one of the earliest Danish programmers. Examined as a mechanical engineer and had worked with electromechanical construction. In 1958 employed at the Danish Regnecentralen, and very soon exhibited an extraordinary programming skill.… …   Wikipedia

  • Simula — Infobox programming language name = Simula paradigm = object oriented year = 1967 designer = Ole Johan Dahl, Kristen Nygaard developer = latest release version = latest release date = latest test version = latest test date = typing =… …   Wikipedia

  • ALGOL — This article is about the programming language family. For other uses, see Algol (disambiguation). ALGOL Paradigm(s) procedural, imperative, structured Appeared in 1958 Designed by Bauer, Bottenbruch, Rutishauser, Samelson, Backus, Katz, Perlis …   Wikipedia

  • Thunk — The word thunk has at least three related meanings in computer science. A thunk may be: * a piece of code to perform a delayed computation (similar to a closure) * a feature of some virtual function table implementations (similar to a wrapper… …   Wikipedia

  • Man or boy test — The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguish compilers that correctly implemented recursion and non local …   Wikipedia

  • Evaluation strategy — Evaluation strategies Strict evaluation Applicative order Call by value Call by reference Call by sharing Call by copy restore Non strict evaluation Normal order Call by name Call by need/Lazy evaluation …   Wikipedia

  • Procedural parameter — In computing, a procedural parameter is a parameter of a procedure that is itself a procedure.This concept is an extremely powerful and versatile programming tool, because it allows programmers to modify certain steps of a library procedure in… …   Wikipedia

  • ALGOL 60 — Die Programmiersprache Algol 60 wurde von 1958–1963 unter der Führung der Association for Computing Machinery (ACM) und der Gesellschaft für Angewandte Mathematik und Mechanik (GAMM), später dann der International Federation for Information… …   Deutsch Wikipedia

  • Algol 60 — Die Programmiersprache Algol 60 wurde 1958–1963 unter der Führung der Association for Computing Machinery (ACM) und der Gesellschaft für Angewandte Mathematik und Mechanik (GAMM), später dann der International Federation for Information… …   Deutsch Wikipedia

  • Thunk (functional programming) — In computer science, a thunk (also suspension, suspended computation or delayed computation) is a parameterless closure created to prevent the evaluation of an expression until forced at a later time. In lazy languages thunks are created and… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”