home.social

#callbyname — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #callbyname, aggregated by home.social.

fetched live
  1. A programming exercise in Common Lisp about Algol-style call-by-name.

    Write the necessary definitions, so that the following works:

    (define-for-calls-by-name sum (i a b v)
    (value a b)
    "Jensen's device."
    (let ((s 0))
    (for (i :from a :to b)
    (incf s v))
    s))

    (defvar *m* (make-array '(2 3)
    :initial-contents '((0 1 2)
    (3 4 5)))
    "A number matrix.")

    (let (i j)
    (assert (eql 3 (sum i 0 2 (aref *m* 0 i))))
    (assert (eql 15 (sum i 0 1 (sum j 0 2 (aref *m* i j))))))

    (assert (string= "Jensen's device."
    (documentation 'sum 'function)))

    As usually with exercises, the value of this is in doing it, rather than in the end result.
    The interesting part is figuring out an approach and the necessary ingredients; writing the program is more or less straightforward.

    #Algol
    #CallByName
    #CommonLisp
    #ComputerProgramming
    #Exercise
    #Lisp
    #ProgrammingPuzzle

  2. > It's really stunning that it does not mention the Scheme language

    So very, very true.

    There are several large pieces of history in this regard that deserve not only to be published, but to be studied well.

    Just a properly written history of closures in computer programming would be worth its weight in gold.
    Even a short history.

    #Algol
    #BlockStructure
    #CallByName
    #Closures
    #HistoryOfComputing
    #Lisp
    #Scheme

    @kentpitman @amoroso