On 2018-02-08, at 12:08:06, Bernd Oppolzer wrote:
Pascal indeed does not have call by name,
I doubt that any modern language has it.
The modern descendant of call by name is lazy evaluation,
which is particularly useful in functional languages.
Usually, the delayed evaluation function (the thunk) is memoized:
which means that the function is executed the first time
it is needed and the resulting value stored. Subsequent references
to the parameter are given the stored value.
In a language with no side-effects, lazy evaluation
with memoization (called "call by need") is equivalent
to call by name. The parameter will only be evaluated
if it is actually needed and will not be evaluated more than once.
It allows programmers to write functions
which return infinite lists and the "same fringe problem":
only as much of the list or fringe
as is actually needed will be evaluated.
It also allows programmers to extend the language:
a new type of conditional statement cannot be defined
as a procedure if procedures evaluate all their arguments
at call time.
In modern languages such as Scheme, the thunks used
to implement call by name can be defined directly
in the language using lambda forms (slightly more
complicated if you also want to assign to the formal parameter!)
C macro parameters also use call by name: writing a swap macro
in C leads to similar problems with writing a swap function
in Algol 60 using call by name.
HLASM macro parameters are also passed call by name.
So call by name is still in use today. (Whether HLASM
counts as a "modern language" or not I will leave
others to decide...)
Finally: I just discovered that the symbol "⏨" used in
the Revised Report on Algol 60 was finally added to Unicode
in 2009 (as U+23E8, "DECIMAL EXPONENT SYMBOL, Algol-60 token
for scientific notation literals").
Dr Martin Ward | Email: mar...@gkc.org.uk | http://www.gkc.org.uk
G.K.Chesterton site: http://www.gkc.org.uk/gkc | Erdos number: 4