• Church numerals in early lisp implementations?

    From Julieta Shem@21:1/5 to McCarthy on Sat May 11 09:23:34 2024
    McCarthy wrote this in ``History of Lisp''.

    Numbers were originally implemented in LISP I as lists of atoms, and
    this proved too slow for all but the simplest computations.

    Was that Church numerals? Does anyone have examples of code from back
    then? I'm picturing things such as

    (defconstant zero nil)
    (defconstant one (cons nil zero))

    (defun zero? (x) (eq zero x))
    (defun add1 (x) (cons nil x))
    (defun sub1 (x) (cdr x))

    (defun add (x y)
    (cond ((zero? x) y)
    (t (add (sub1 x) (add1 y)))))

    CL-USER> (add one one)
    (NIL NIL)

    The paragraph continued:

    A reasonably efficient implementation of numbers as atoms in
    S-expressions was made in LISP 1.5, but in all the early LISPs,
    numerical computations were still 10 to 100 times slower than in
    FORTRAN. Efficient numerical computation requires some form of typing
    in the source language and a distinction between numbers treated by themselves and as elements of S-expressions. Some recent versions of
    LISP allow distinguishing types, but at the time, this seemed
    incompatible with other features.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Daniel Cerqueira@21:1/5 to Julieta Shem on Sat May 11 14:44:07 2024
    Julieta Shem <jshem@yaxenu.org> writes:

    McCarthy wrote this in ``History of Lisp''.

    Numbers were originally implemented in LISP I as lists of atoms, and
    this proved too slow for all but the simplest computations.

    Was that Church numerals? Does anyone have examples of code from back
    then? I'm picturing things such as

    (defconstant zero nil)
    (defconstant one (cons nil zero))

    (defun zero? (x) (eq zero x))
    (defun add1 (x) (cons nil x))
    (defun sub1 (x) (cdr x))

    (defun add (x y)
    (cond ((zero? x) y)
    (t (add (sub1 x) (add1 y)))))

    CL-USER> (add one one)
    (NIL NIL)

    The paragraph continued:

    A reasonably efficient implementation of numbers as atoms in
    S-expressions was made in LISP 1.5, but in all the early LISPs,
    numerical computations were still 10 to 100 times slower than in
    FORTRAN. Efficient numerical computation requires some form of typing
    in the source language and a distinction between numbers treated by
    themselves and as elements of S-expressions. Some recent versions of
    LISP allow distinguishing types, but at the time, this seemed
    incompatible with other features.

    Wow! I am also interested in knowing this. I like this early LISP stuff
    :-) .

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alan Bawden@21:1/5 to McCarthy on Sat May 11 21:43:22 2024
    Julieta Shem <jshem@yaxenu.org> writes:

    McCarthy wrote this in ``History of Lisp''.

    > Numbers were originally implemented in LISP I as lists of atoms, and
    > this proved too slow for all but the simplest computations.

    Was that Church numerals?

    Certainly not.

    The "atoms" is question were probably machine words containing the
    digits of the number in some suitable base. I would guess base 2^36 or
    2^35, depending on how they chose to represent negative numbers --
    similar to the way GMP still works today. But I don't know for sure.
    I've never seen this documented anywhere.

    - Alan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julieta Shem@21:1/5 to Alan Bawden on Sun May 12 16:55:46 2024
    Alan Bawden <alan@csail.mit.edu> writes:

    Julieta Shem <jshem@yaxenu.org> writes:

    McCarthy wrote this in ``History of Lisp''.

    > Numbers were originally implemented in LISP I as lists of atoms, and
    > this proved too slow for all but the simplest computations.

    Was that Church numerals?

    Certainly not.

    The "atoms" is question were probably machine words containing the
    digits of the number in some suitable base. I would guess base 2^36 or
    2^35, depending on how they chose to represent negative numbers --
    similar to the way GMP still works today. But I don't know for sure.
    I've never seen this documented anywhere.

    Do you know if they have big numbers in those early implementations?
    (Why would they use a list of things?) I'm now thinking that by ``list
    of atoms'' (and with the light of from your post) they were supporting
    big numbers. Their algorithms were perhaps naive, explaining ``the too
    slow for all but the simplest computations''. Thanks!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to steve on Thu May 16 23:01:47 2024
    On Thu, 16 May 2024 16:28:01 -0400, steve wrote:

    check turning machine.

    Sounds like some kind of scam operation.

    “The police raid of the check-turning operation arrested a dozen people
    and seized half a dozen check-turning machines.”

    “You are on trial for 350 counts of check-turning. How do you plead?”

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Monnier@21:1/5 to All on Tue May 21 12:30:37 2024
    “The police raid of the check-turning operation arrested a dozen people
    and seized half a dozen check-turning machines.”

    “You are on trial for 350 counts of check-turning. How do you plead?”

    Thanks!


    Stefan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)