Discussion:
Lisp programming questions
(too old to reply)
Ishaan
2020-09-25 19:59:53 UTC
Permalink
Hi,
I'm a high school student interested in programming and I need some help with lisp.

I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
His Kennyness
2020-09-25 23:47:02 UTC
Permalink
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
You should be up to speed pretty quickly. It just seems different. Once you get past the superficial syntax differences you should be fine.

What tutorial are you following?
Ishaan
2020-09-26 00:08:53 UTC
Permalink
Post by His Kennyness
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
You should be up to speed pretty quickly. It just seems different. Once you get past the superficial syntax differences you should be fine.
What tutorial are you following?
"Practical Common Lisp" by Peter Siebel. Are their any good alternatives to Emacs and lisp in a box that are easier to use? Thanks for the help!
José Manuel García-Patos
2020-09-26 11:58:32 UTC
Permalink
Post by Ishaan
Post by His Kennyness
What tutorial are you following?
"Practical Common Lisp" by Peter Siebel. Are their any good alternatives
to Emacs and lisp in a box that are easier to use? Thanks for the help!
That's a pretty good book, and Emacs with Slime is the best setup IMO, so
I assume your issues are elsewhere. What troubles are you having exactly?
And what implementation are you using? SBCL? CLISP? CMUCL? Allegro?
--
José Manuel García-Patos
Madrid
His Kennyness
2020-09-27 10:27:16 UTC
Permalink
Post by Ishaan
Post by His Kennyness
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
You should be up to speed pretty quickly. It just seems different. Once you get past the superficial syntax differences you should be fine.
What tutorial are you following?
"Practical Common Lisp" by Peter Siebel. Are their any good alternatives to Emacs and lisp in a box that are easier to use? Thanks for the help!
What OS are you on? Franz has a great Common Lisp IDE, but it runs only on Windows. https://franz.com/products/allegro-common-lisp/ If you have access to a WIndows box get their free version.

Lispworks would be another good alternative. On MacOS, not sure what is up with Clozure CL, but they used to have a very nice IDE.

Otherwise, I am afraid it is best to deal with Emacs+Slime. A few painful days and you will be fine, and you will be able to use Emacs for anything.

Practical Common Lisp is what I would have recommended, so good. If you have the $$$, this is great: https://www.amazon.com/ANSI-Common-LISP-Paul-Graham/dp/0133708756.

Have fun.
Tom Russ
2020-09-28 16:38:43 UTC
Permalink
Post by His Kennyness
What OS are you on? Franz has a great Common Lisp IDE, but it runs only on Windows. https://franz.com/products/allegro-common-lisp/ If you have access to a WIndows box get their free version.
Lispworks would be another good alternative. On MacOS, not sure what is up with Clozure CL, but they used to have a very nice IDE.
CCL is still available on MacOS from the Apple Store. It is a free download.

It has been a little balky with some of the new operating systems (like Catalina), with error messages appearing in "Alt Console".
Oddly enough, though, I find that launching it a couple of times in succession and just quitting (Command-Q) from the error dialog will get it to work after about 3 tries or so. But it is sufficiently unreliable that I can't recommend it to a new user.
His Kennyness
2020-09-28 16:46:19 UTC
Permalink
Post by Tom Russ
Post by His Kennyness
What OS are you on? Franz has a great Common Lisp IDE, but it runs only on Windows. https://franz.com/products/allegro-common-lisp/ If you have access to a WIndows box get their free version.
Lispworks would be another good alternative. On MacOS, not sure what is up with Clozure CL, but they used to have a very nice IDE.
CCL is still available on MacOS from the Apple Store. It is a free download.
It has been a little balky with some of the new operating systems (like Catalina), with error messages appearing in "Alt Console".
Oddly enough, though, I find that launching it a couple of times in succession and just quitting (Command-Q) from the error dialog will get it to work after about 3 tries or so. But it is sufficiently unreliable that I can't recommend it to a new user.
Oh, wow, I just fired it up and this time it is working. (On Catalina.) Maybe I got lucky.

Well, if the OP is on the Mac it would not hurt to try I guess.
Ishaan
2020-09-28 20:14:38 UTC
Permalink
Post by His Kennyness
Post by Ishaan
Post by His Kennyness
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
You should be up to speed pretty quickly. It just seems different. Once you get past the superficial syntax differences you should be fine.
What tutorial are you following?
"Practical Common Lisp" by Peter Siebel. Are their any good alternatives to Emacs and lisp in a box that are easier to use? Thanks for the help!
What OS are you on? Franz has a great Common Lisp IDE, but it runs only on Windows. https://franz.com/products/allegro-common-lisp/ If you have access to a WIndows box get their free version.
Lispworks would be another good alternative. On MacOS, not sure what is up with Clozure CL, but they used to have a very nice IDE.
Otherwise, I am afraid it is best to deal with Emacs+Slime. A few painful days and you will be fine, and you will be able to use Emacs for anything.
Practical Common Lisp is what I would have recommended, so good. If you have the $$$, this is great: https://www.amazon.com/ANSI-Common-LISP-Paul-Graham/dp/0133708756.
Have fun.
Thanks for recommending LispWorks! I like it a lot so far!
I checked out a not exactly legal (sorry, Paul Graham) copy of ANSI Common Lisp, and have read the first few pages, thanks for the recommendation!

I'm truly grateful for everyone's help and recommendations,
Ishaan
smh
2020-09-30 19:32:15 UTC
Permalink
Post by His Kennyness
What OS are you on? Franz has a great Common Lisp IDE, but it runs only on Windows. https://franz.com/products/allegro-common-lisp/ If you have access to a WIndows box get their free version.
Not quite up to date, Kenny. The IDE also runs on Linux and MacOS and FreeBSD. The free "Express" downloads were traditionally all 32-bit, but I recently heard that some 64-bit versions were available.
His Kennyness
2020-09-30 20:32:54 UTC
Permalink
Post by His Kennyness
What OS are you on? Franz has a great Common Lisp IDE, but it runs only on Windows. https://franz.com/products/allegro-common-lisp/ If you have access to a WIndows box get their free version.
Not quite up to date, Kenny. The IDE also runs on Linux and MacOS and FreeBSD. The free "Express" downloads were traditionally all 32-bit, but I recently heard that some 64-bit versions were available.
Steve! How the Hell are you?!!! We had someone here who wanted us to re-open the CL spec, where were you to chase him away with the appropriate standards process horror stories?!!

Meanwhile, I am disappointed you think so little of His Kennyness to think I would not grab the latest versions of anything before commenting. This stings. :) I certainly did, and just did so again, and ironically I have gotten the gem running (yay!) by *failing* to follow the Byzantine albeit finally excellent doc. What happened on https://franz.com/support/documentation/10.1/doc/installation.htm#macosx-install-1 was that I skipped the installation "goto" to an Express-specific set of instructions and fell thru to the problem solution, viz., the Catalina X11 upgrade requirement at https://franz.com/support/documentation/10.1/doc/installation.htm#macosx-install-gtk-3. Massive kudos for this info there: "The symptom of a broken XQuartz is blank rectangles that should be filled with text". Bingo!

So thanks for urging me once more into the breach! I know we do not need to review Dijkstra on GOTOs https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf, and indeed it is unlikely a gosub would work with most readers, so I recommend duplicating the Catalina/GTk warning in the express directions. I did that and the IDE came up nicely -- congrats!!!!!!!!!

Can you approve my invoice for this work?

cheers, hk
Arseny Slobodyuk
2020-09-26 11:45:33 UTC
Permalink
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
I recommend "Lisp Notes" https://www.cs.ccu.edu.tw/~dan/lispnotes.txt to
everybody. It never works out but anyway. I think it contains just a
necessary amount to feel the spirit. It is an excerpt from the
D.Touretzky's "A gentle introduction to symbolics computation".
Arseny Slobodyuk
2020-09-26 11:53:56 UTC
Permalink
Post by Arseny Slobodyuk
necessary amount to feel the spirit. It is an excerpt from the
D.Touretzky's "A gentle introduction to symbolics computation".
Oh and have the CLTL2 by Guy L. Steele by hand.
Ishaan
2020-09-28 19:33:05 UTC
Permalink
Post by Arseny Slobodyuk
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
I recommend "Lisp Notes" https://www.cs.ccu.edu.tw/~dan/lispnotes.txt to
everybody. It never works out but anyway. I think it contains just a
necessary amount to feel the spirit. It is an excerpt from the
D.Touretzky's "A gentle introduction to symbolics computation".
Thanks, I really like the humane voice it's written in!
none) (albert
2020-10-01 14:32:14 UTC
Permalink
Post by Ishaan
Post by Arseny Slobodyuk
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some
help with lisp.
Post by Arseny Slobodyuk
Post by Ishaan
I've been trying to learn the basics for the past few days and
everything about it confuses me. I'm ok at javascript and python, but
this really trips me up. I just can't anything to work, and I've never
been so frustrated at a computer. Also how long should it take to be
able to write decent programs in lisp and descendent dialects?
Post by Arseny Slobodyuk
I recommend "Lisp Notes" https://www.cs.ccu.edu.tw/~dan/lispnotes.txt to
everybody. It never works out but anyway. I think it contains just a
necessary amount to feel the spirit. It is an excerpt from the
D.Touretzky's "A gentle introduction to symbolics computation".
Thanks, I really like the humane voice it's written in!
I have not quite come to the end of those lispnotes.txt.
I wanted to distill a test that I pass to clisp (apparently some
common lisp) that is installed on my ubuntu system.
I have a list of mistakes and inaccuracies attached, with tentative fixes
mostly.
In particular I'd like help with the following numbers that I couldn't
fix myself:
14
17
21 no clue
22
24
25
26
-------------------------------------------------
1 O is used instead of 0
l is used instead if 1
2 d is used instead of e
3. (number 5.0) doesn't give a random float.
(random 5.0) however does
4. /SUM is not known in clisp
5. (last )(a b c . d))
must be
. (last '(a b c . d))
6. (remove 'a) ](b a n a n a))
must be
(remove 'a '(b a n a n a))
7
; fails, commented out
;(give-title '(john peterson))
;(mr john peterson)
8
(assoc 'four quatre)
;(four words)
must be ??
(assoc 'four words)
;(four quatre)
9
; fails, commented out
;(quality-difference 'object2 'object3)
;material
;

10
; fails
;(quality-difference 'object2 'object3)
;material

11
( eq 3 3)
; Error: wrong input type
;
in clisp this results in
;t

12
(funcall fn 'a 'b) a
must be
(funcall fn 'a 'b)

13
(eval ''boing)
;'boing
in clisp this results in
; boing

14
;(eval (eval ''boing))
;boing
in clisp this results in
*** - EVAL: variable BOING has no value

15
(mapcar #'(lambda (n) (* n n)) '(1 2 3 4 5)
must be
(mapcar #'(lambda (n) (* n n)) '(1 2 3 4 5))

16
(mapcar #'(lambda (n) (* 10 n)) '(1 2 3 4 5)
must be
(mapcar #'(lambda (n) (* 10 n)) '(1 2 3 4 5))

17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION :LAMBDA (N) (* N 10)>

18
(find-if #'oddp ](2 4 6 7 8 9))
must be
(find-if #'oddp '(2 4 6 7 8 9))

19
(reduce #'(lambda (x y)
(+ (* x X) (* y y))))
'(1 2 3))
must be
(reduce #'(lambda (x y)
(+ (* x X) (* y y)))
'(1 2 3))

20
(defun fact (n)
(cond ((zerop n) 1)
(t (* n (fact (- n 1)))))
one closing bracket is missing.

21
(defun my-length (1)
(cond ((null 1) 0)
(t (+ 1 (my-length (cdr 1))))))
meets with error message
*** - DEFUN: Invalid lambda list element 1. A lambda list may only contain
symbols and lists.

22
(defun fib (n)
(+ (fib (- n 1)
(fib - n 2))))
tracin fails with "too many arguments given to FIB"
replaced with
too many arguments given to FIB

23
(find-first-atom '(((a b) c) d)) a
The a is spurious

24
(my-nth 2 '(a b c d e))
fails with error
USE-VALUE :R1 Input a value to be used instead of I.
The problem is probably with:
(defun my-nth (n x) (cond ((zerop n) (car x))
(t (my-nth (- n i) (cdr x)))))
;
25
There is probably an error in
(defun fib (n)
(cond ((equal n 0) 1)
((equal n 1) 1)
(t (+ (fib (- n 1)
(- n 2))))))
because (fib 3 ) gives
*** - EVAL/APPLY: too many arguments given to FIB

26
count-up is not defined in clisp
--
This is the first day of the end of your life.
It may not kill you, but it does make your weaker.
If you can't beat them, too bad.
***@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Arseny Slobodyuk
2020-10-02 14:18:03 UTC
Permalink
On 02.10.2020 00:32, albert wrote:

Wow, you certainly gave it a go! It looked much smarter when I started
to learn lisp!
BTW, you mentioned clisp and I recalled that clisp distro has a similar
file named LISP-tutorial.txt I believe it contains much less typos.
I might be mixed those tutorials in my memory into a single one.
Post by none) (albert
13
(eval ''boing)
;'boing
in clisp this results in
; boing
14
;(eval (eval ''boing))
;boing
in clisp this results in
*** - EVAL: variable BOING has no value
IDK, clisp is correct here. In the book there are one more quote.
Post by none) (albert
17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION LAMBDA (N) (* N 10)>
The modern way is #'(lambda (n) (* n 10))
Post by none) (albert
21
(defun my-length (1)
(cond ((null 1) 0)
(t (+ 1 (my-length (cdr 1))))))
meets with error message
*** - DEFUN: Invalid lambda list element 1. A lambda list may only contain
symbols and lists.
1 instead of l

* (defun my-length (l)
(cond ((null l) 0)
(t (+ 1 (my-length (cdr l))))))
MY-LENGTH
* (my-length '(a b c d e f g))
7
Post by none) (albert
22
(defun fib (n)
(+ (fib (- n 1)
(fib - n 2))))
tracin fails with "too many arguments given to FIB"
replaced with
too many arguments given to FIB
(defun fib (n)
(+ (fib (- n 1))
(fib (- n 2))))
Still infinite.
Post by none) (albert
24
(my-nth 2 '(a b c d e))
fails with error
USE-VALUE :R1 Input a value to be used instead of I.
(defun my-nth (n x) (cond ((zerop n) (car x))
(t (my-nth (- n i) (cdr x)))))
i instead of 1

* (defun my-nth (n x) (cond ((zerop n) (car x))
(t (my-nth (- n 1) (cdr x)))))
MY-NTH
* (my-nth 4 '(a b c d e f g))
E
Post by none) (albert
26
count-up is not defined in clisp
Come on, it is defined right there, after that call!
none) (albert
2020-10-02 15:26:46 UTC
Permalink
Post by Arseny Slobodyuk
Wow, you certainly gave it a go! It looked much smarter when I started
to learn lisp!
BTW, you mentioned clisp and I recalled that clisp distro has a similar
file named LISP-tutorial.txt I believe it contains much less typos.
I might be mixed those tutorials in my memory into a single one.
Thanks. That tutorial is useful and probably more reliable.
It is more elaborate on the basics, and less on the more advanced
topics.
Post by Arseny Slobodyuk
Post by none) (albert
13
(eval ''boing)
;'boing
in clisp this results in
; boing
Am I correct that first ''boing is evaluated giving 'boing
then passed to eval giving boing ?
Post by Arseny Slobodyuk
Post by none) (albert
17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION LAMBDA (N) (* N 10)>
The modern way is #'(lambda (n) (* n 10))
That notation is there too, as a test.
The official way seems to be
(function (lambda (n) (*n 10))
and the #' looks like a superfluous idosyncracy to me.
I tried it in scheme and evaluating the `` (lambda .. '' list
results in an anonumous function. That makes much more sense to
me.
Post by Arseny Slobodyuk
Post by none) (albert
21
(defun my-length (1)
(cond ((null 1) 0)
(t (+ 1 (my-length (cdr 1))))))
meets with error message
*** - DEFUN: Invalid lambda list element 1. A lambda list may only contain
symbols and lists.
1 instead of l
I knew it!
Post by Arseny Slobodyuk
* (defun my-length (l)
(cond ((null l) 0)
(t (+ 1 (my-length (cdr l))))))
MY-LENGTH
* (my-length '(a b c d e f g))
7
Post by none) (albert
22
(defun fib (n)
(+ (fib (- n 1)
(fib - n 2))))
tracin fails with "too many arguments given to FIB"
replaced with
too many arguments given to FIB
(defun fib (n)
(+ (fib (- n 1))
(fib (- n 2))))
Still infinite.
thanks
Post by Arseny Slobodyuk
Post by none) (albert
24
(my-nth 2 '(a b c d e))
fails with error
USE-VALUE :R1 Input a value to be used instead of I.
(defun my-nth (n x) (cond ((zerop n) (car x))
(t (my-nth (- n i) (cdr x)))))
i instead of 1
* (defun my-nth (n x) (cond ((zerop n) (car x))
(t (my-nth (- n 1) (cdr x)))))
thanks
Post by Arseny Slobodyuk
MY-NTH
* (my-nth 4 '(a b c d e f g))
E
Post by none) (albert
26
count-up is not defined in clisp
Come on, it is defined right there, after that call!
The test (count-up 5) failed me. It would probably succeed
on a psychic lisp that knew what definitions were following
in a streaming input.

Again, thanks.

Groetjes Albert
--
This is the first day of the end of your life.
It may not kill you, but it does make your weaker.
If you can't beat them, too bad.
***@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Paul Rubin
2020-10-02 17:55:26 UTC
Permalink
Post by none) (albert
Thanks. That tutorial is useful and probably more reliable.
It is more elaborate on the basics, and less on the more advanced
topics.
I remember looking at some Lisp tutorials in high school, trying a few
things, but not really getting it. What made me understand Lisp was
reading the source code (written in C) of the Emacs Lisp interpreter.

Did you not have any luck with SICP? I'd have expected it to map well
to your mathematical interests.
none) (albert
2020-10-03 12:14:22 UTC
Permalink
Post by Paul Rubin
Post by none) (albert
Thanks. That tutorial is useful and probably more reliable.
It is more elaborate on the basics, and less on the more advanced
topics.
I remember looking at some Lisp tutorials in high school, trying a few
things, but not really getting it. What made me understand Lisp was
reading the source code (written in C) of the Emacs Lisp interpreter.
Did you not have any luck with SICP? I'd have expected it to map well
to your mathematical interests.
I'm not actually trying to get it. I know that will take another
5 years of intensive usage, which could be brought about by
doing the euler problems in lisp and working through all examples
of SICP. I have read through SICP and learned something.
My real focus is on what is at the heart of lisp w.r.t. required
compilation facilities and how to implement that.

Groetjes Albert
--
This is the first day of the end of your life.
It may not kill you, but it does make your weaker.
If you can't beat them, too bad.
***@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Arseny Slobodyuk
2020-10-03 01:04:38 UTC
Permalink
Post by none) (albert
Post by Arseny Slobodyuk
Post by none) (albert
13
(eval ''boing)
;'boing
in clisp this results in
; boing
Am I correct that first ''boing is evaluated giving 'boing
then passed to eval giving boing ?
Right, one evaluation is performed by the lisp REPL system or,
in the non-interactive mode just by the lisp system and another
evaluation is ordered explicitly. Each one strips one quote.
Post by none) (albert
Post by Arseny Slobodyuk
Post by none) (albert
17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION LAMBDA (N) (* N 10)>
The modern way is #'(lambda (n) (* n 10))
That notation is there too, as a test.
The official way seems to be
(function (lambda (n) (*n 10))
and the #' looks like a superfluous idosyncracy to me.
I tried it in scheme and evaluating the `` (lambda .. '' list
results in an anonumous function. That makes much more sense to
me.
We don't talk about redefining lambda, it's sacred.
There's some old style behavior left in clisp, that's why it accepts the
bare lambda form. I believe it's from some ancient lisp dialect which
was closer to what you want, but as soon as common lisp got separate
value and function slots in the symbol cells, there emerged a need in
the function quotation mechanism.
Post by none) (albert
Again, thanks.
You've made a fair amount of work! I put all the corrections in the file
but it needs a couple more checks. So I believe this version is worth to
be put somewhere. I can publish it on my sourceforge corner later, or
you can put it on your forth page or maybe it's better to put it on cliki?
Kaz Kylheku
2020-10-03 01:47:00 UTC
Permalink
Post by Arseny Slobodyuk
Post by none) (albert
Post by Arseny Slobodyuk
Post by none) (albert
13
(eval ''boing)
;'boing
in clisp this results in
; boing
Am I correct that first ''boing is evaluated giving 'boing
then passed to eval giving boing ?
Right, one evaluation is performed by the lisp REPL system or,
in the non-interactive mode just by the lisp system and another
evaluation is ordered explicitly. Each one strips one quote.
Post by none) (albert
Post by Arseny Slobodyuk
Post by none) (albert
17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION LAMBDA (N) (* N 10)>
The modern way is #'(lambda (n) (* n 10))
That notation is there too, as a test.
The official way seems to be
(function (lambda (n) (*n 10))
and the #' looks like a superfluous idosyncracy to me.
I tried it in scheme and evaluating the `` (lambda .. '' list
results in an anonumous function. That makes much more sense to
me.
We don't talk about redefining lambda, it's sacred.
There's some old style behavior left in clisp, that's why it accepts the
bare lambda form. I believe it's from some ancient lisp dialect which
was closer to what you want, but as soon as common lisp got separate
value and function slots in the symbol cells, there emerged a need in
the function quotation mechanism.
Be that as it may, the quotation mechanism is not required for lambda,
even in a Lisp-2.

This is because a lambda expression isn't a binding to be resolved; it
stands for itself literally.

The existence of the lambda macro in CL tells us that we don't want a
lambda expression to have a different meaning in the first position of a
form versus in the subsequent positions, and it tells us that there is
room for a lambda operator in a Lisp-2.

So actually a reverse situation is the case: a Lisp-2 which happens to
have a genuine lambda special form, and which (necessarily) has function
operator does need that function operator to also recognize lambda:
(function (lambda ...)) has to behave like just (lambda ...).

This is for consistency. Basically we want things to be such that
(function X) accepts any X that can also be used in the operator
position (X ...) and that denotes a function.

For instance, if someone writes a macro like this:

(defmacro mymac (function-name)
`(... (bloop #',function-name ...)))

which blindly sticks the function-name into a (function ...)
expression, it is nice if that works with a lambda expression.

The same goes for this one:

(defmacro mymac2 (function-name)
`(... (,function-name ...)))
--
TXR Programming Language: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
Arseny Slobodyuk
2020-10-03 06:24:30 UTC
Permalink
Post by Kaz Kylheku
This is for consistency. Basically we want things to be such that
(function X) accepts any X that can also be used in the operator
position (X ...) and that denotes a function.
Sorry, didn't understand this. You can't put lambda in an operator
position. But I see your point about consistency.

I was wrong about the "bare lambda". I probably confused it with a "list
form" of lambda. I believe there was a time when you could pass a lambda
expression to funcall or apply in clisp e.g. (funcall '(lambda (x) (* x
x)) 2). So I used it. And then it was forbidden in 1998 (according to
the clisp changelog):

1998-05-18 Bruno Haible ...

* error.d (fehler_lambda_expression): New function.
* eval.d (coerce_function): Accept symbols, but reject lambda
expressions.
(apply, funcall): Reject lambda expressions.
Zyni Moë
2020-10-03 14:50:54 UTC
Permalink
Post by Arseny Slobodyuk
I was wrong about the "bare lambda". I probably confused it with a "list
form" of lambda. I believe there was a time when you could pass a lambda
expression to funcall or apply in clisp e.g. (funcall '(lambda (x) (* x
x)) 2). So I used it. And then it was forbidden in 1998 (according to
Some old CL impls used to be OK with (funcall '(lambda ...) ...) at least,
but not sure was ever allowed even by CLtL1.

Macro for LAMBDA so (lambda ...) expands to (function (lambda ...)) was
quite late in standards process, may not be in CLtL2, was needed for ISLISP
compat as user can not define macro for LAMBDA (many did though of course)
in CL. Don't remember if ((lambda ...) ...) was always allowed.

Tried to check my copies of CLtL1, 2 but seem to have been eaten by worms,
damp and dust.
--
the small snake
Kaz Kylheku
2020-10-04 15:55:27 UTC
Permalink
Post by Arseny Slobodyuk
Post by Kaz Kylheku
This is for consistency. Basically we want things to be such that
(function X) accepts any X that can also be used in the operator
position (X ...) and that denotes a function.
Sorry, didn't understand this. You can't put lambda in an operator
position. But I see your point about consistency.
You mean in Common Lisp? Sure you can.

((lambda (x y) (+ x y)) 1 2) -> 3

This is documented in under "Symbol LAMBDA" in 3.8, The Evaluation and
Compilation Dictionary:

Notes:

The lambda form

((lambda lambda-list . body) . arguments)

is semantically equivalent to the function form

(funcall #'(lambda lambda-list . body) . arguments)
Post by Arseny Slobodyuk
I was wrong about the "bare lambda". I probably confused it with a "list
form" of lambda.
The "list form of lambda" and "lambda expression" are the same thing:
a list headed by the lambda symbol conforming to some syntax.
Post by Arseny Slobodyuk
I believe there was a time when you could pass a lambda
expression to funcall or apply in clisp e.g. (funcall '(lambda (x) (* x
x)) 2). So I used it. And then it was forbidden in 1998 (according to
This means that you have a run-time lambda expression: you're trying to
process the source code of a lambda expression at run-time.

Common Lisp doesn't require funcall to coerce the source code of a
lambda expression to the function that it denotes.

You can do it with coerce, though:

$ clisp -q
[1]> (funcall (coerce '(lambda (x y) (+ x y)) 'function) 3 2)
5

This coerce + funcall is "backward compatible" with funcall:

[2]> (funcall (coerce 'list 'function) 3 2)
(3 2)
[3]> (funcall (coerce #'list 'function) 3 2)
(3 2)

Allowing funcall to take a list argument would interfere with the
possible useful extension of allowing sequences to be funcallable
objects.

For instance, you might want it so that (funcall "abc" 1) yields #\a,
and a similar thing works for vectors and lists.
--
TXR Programming Language: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
Arseny Slobodyuk
2020-10-05 04:03:54 UTC
Permalink
Post by Kaz Kylheku
You mean in Common Lisp? Sure you can.
((lambda (x y) (+ x y)) 1 2) -> 3
Thank you Kaz, it seems that I missed this.
I look at the function special form as at the special coercion tool,
much like string function.
* (function string)
#<FUNCTION STRING>
* (string 'function)
"FUNCTION"
They have in common that feature that they do less than they could (I
believe it can do less than coerce. At least when coercing to string, I
never used it for functions.). But they do conversions required for the
language core. There's no perfect symmetry though since the first is a
special form and does not evaluate its argument.
Post by Kaz Kylheku
For instance, you might want it so that (funcall "abc" 1) yields #\a,
and a similar thing works for vectors and lists.
In no circumstances I'd want this.
Zyni Moë
2020-10-05 09:17:50 UTC
Permalink
Post by Arseny Slobodyuk
I look at the function special form as at the special coercion tool,
much like string function.
FUNCTION is machine that accesses the function namespace. Function
namespace, unlike variable namespace, contains countably infinite number of
bindings.
Post by Arseny Slobodyuk
Post by Kaz Kylheku
For instance, you might want it so that (funcall "abc" 1) yields #\a,
and a similar thing works for vectors and lists.
In no circumstances I'd want this.
This really is message passing. (funcall "foo" '+ "bar") could just be
(send "foo" '+ "bar") could just be ("foo" '+ "bar") -> "foobar". Entire
languages have been built on this.
--
the small snake
Arseny Slobodyuk
2020-10-05 22:27:40 UTC
Permalink
Post by Zyni Moë
Post by Arseny Slobodyuk
I look at the function special form as at the special coercion tool,
much like string function.
FUNCTION is machine that accesses the function namespace. Function
namespace, unlike variable namespace, contains countably infinite number of
bindings.
It's very exciting but I believe is just another phrasing of the fact
that it's non-evaluating its argument. I'll better stick with the cltl2:

function fn
The value of function is always the functional interpretation of fn
Post by Zyni Moë
Post by Arseny Slobodyuk
Post by Kaz Kylheku
For instance, you might want it so that (funcall "abc" 1) yields #\a,
and a similar thing works for vectors and lists.
In no circumstances I'd want this.
This really is message passing. (funcall "foo" '+ "bar") could just be
(send "foo" '+ "bar") could just be ("foo" '+ "bar") -> "foobar". Entire
languages have been built on this.
But what message is passed in the Kaz's case? "You know what to do, do it"?
Kaz Kylheku
2020-10-06 00:20:34 UTC
Permalink
Post by Arseny Slobodyuk
Post by Zyni Moë
Post by Arseny Slobodyuk
I look at the function special form as at the special coercion tool,
much like string function.
FUNCTION is machine that accesses the function namespace. Function
namespace, unlike variable namespace, contains countably infinite number of
bindings.
It's very exciting but I believe is just another phrasing of the fact
Note that "not evaluating its argument" is just what the operator
doesn't do; it doesn't inform us what the operator *does*.

It's like saying that your family doctor doesn't fill cavities, or put
on crowns, which is well and true.

The function operator does in fact evaluate; it treats its argument as
an expression which produces a value---only, it does that according to
altered evaluation semantics.

If the syntax is a symbol, that symbol is subject to a lexical lookup in
the function namespace. In a Lisp-1, we would obtain that same effect
simply by writing that symbolic expression without any function
operator wrapped around it, since the function would be in the ordinary
variable namespace.
Post by Arseny Slobodyuk
function fn
The value of function is always the functional interpretation of fn
Post by Zyni Moë
Post by Arseny Slobodyuk
Post by Kaz Kylheku
For instance, you might want it so that (funcall "abc" 1) yields #\a,
and a similar thing works for vectors and lists.
In no circumstances I'd want this.
This really is message passing. (funcall "foo" '+ "bar") could just be
(send "foo" '+ "bar") could just be ("foo" '+ "bar") -> "foobar". Entire
languages have been built on this.
But what message is passed in the Kaz's case? "You know what to do, do it"?
The idea is that an array is actually a function: a mapping from indices
to values. This suggests that if an array is made funcallable, what it
could do is accept a single argument, which represents an index, and
return the value. This could be paired with a "setter" function which
stores a new value in a mutable array. Similarly, if a hash table is
funcallable, it can do key lookup.

The "message passing" interpretation of (funcall sequence index) is that
the sequence object receives the index as a message. For instance
#(1 2 3) receives the message 1, and this tells it to retrieve 2.
--
TXR Programming Language: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
Arseny Slobodyuk
2020-10-06 03:55:16 UTC
Permalink
Post by Kaz Kylheku
Post by Arseny Slobodyuk
Post by Zyni Moë
FUNCTION is machine that accesses the function namespace. Function
namespace, unlike variable namespace, contains countably infinite number of
bindings.
It's very exciting but I believe is just another phrasing of the fact
Note that "not evaluating its argument" is just what the operator
doesn't do; it doesn't inform us what the operator *does*.
I believe we all know what the function operator does. The discussion is
about what it does mean. The standard does not contain much philosophy
to rely upon. I understand it that Zyni says the function searches in
infinite namespace function named (lambda (x) (* x x)) and return the
corresponding function object. I don't like that interpretation since it
is much like to the meaningless application of the sets theory to
everything which "explains" everything and does not help much.
Post by Kaz Kylheku
The function operator does in fact evaluate; it treats its argument as
an expression which produces a value---only, it does that according to
altered evaluation semantics.
Well, of course as an useful operator it does something. I miss
evaluation in it since I believe its evaluation is what does all the
magic. If I have a lambda list (or a symbol name) in a variable f, I
need to do (eval (list 'function f)) to obtain the function object. For
static lambda lists (and symbols) the function object emerges after
evaluation performed by the lisp system, so there's no explicit eval.
Post by Kaz Kylheku
The "message passing" interpretation of (funcall sequence index) is that
the sequence object receives the index as a message. For instance
#(1 2 3) receives the message 1, and this tells it to retrieve 2.
Oh, I see. Still does not not seem very practical to me. Except that it
possibly
could be a great basis for some special automata language... I usually
make every attempt to avoid extracting
array or list elements one by one.
Zyni Moë
2020-10-06 11:00:05 UTC
Permalink
Post by Arseny Slobodyuk
Well, of course as an useful operator it does something. I miss
evaluation in it since I believe its evaluation is what does all the
magic. If I have a lambda list (or a symbol name) in a variable f, I
need to do (eval (list 'function f)) to obtain the function object. For
static lambda lists (and symbols) the function object emerges after
evaluation performed by the lisp system, so there's no explicit eval.
If you want function from thing you say (coerce thing 'function). And
(coerce '(lambda (x) y) 'function) is not the same as (function (lambda (x)
y)). When you understand that perhaps you will understand why FUNCTION
must exist in lexically-scoped Lisp-2.
--
the small snake
Nils M Holm
2020-10-06 07:35:59 UTC
Permalink
Post by Kaz Kylheku
Post by Arseny Slobodyuk
It's very exciting but I believe is just another phrasing of the fact
Note that "not evaluating its argument" is just what the operator
doesn't do; it doesn't inform us what the operator *does*.
Interestingly, in early LISP these two interpretations were exactly
the same. FUNCTION was merely an alias of QUOTE in LISP 1.5, LISP 1.6,
and (early?) MACLISP, so "what it does" and "what it does not do"
basically said the same thing! (LISP 1 was a LISP-1, so it did not
have a FUNCTION form).
--
Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
Jeff Barnett
2020-10-06 07:53:55 UTC
Permalink
Post by Nils M Holm
Post by Kaz Kylheku
Post by Arseny Slobodyuk
It's very exciting but I believe is just another phrasing of the fact
Note that "not evaluating its argument" is just what the operator
doesn't do; it doesn't inform us what the operator *does*.
Interestingly, in early LISP these two interpretations were exactly
the same. FUNCTION was merely an alias of QUOTE in LISP 1.5, LISP 1.6,
and (early?) MACLISP, so "what it does" and "what it does not do"
basically said the same thing! (LISP 1 was a LISP-1, so it did not
have a FUNCTION form).
Well some Lisp 1.5 implementations had a "label" form which was used as
(LABEL FOO (LAMBDA (X Y Z) ... (FOO A B C) ...))
The label allowed the lambda to call itself recursively; in the example,
(FOO A B C) was the recursive call. (Label acted like function but
provided a handle to the function so defined.) However, I don't clearly
remember two things about this: 1) Could a nested lambda see the outer
label name? and 2) Did the label name block an outer global function
and, if so, how and when? The implementation usually compiled the lambda
expression using a gensym name and put the code in the outer global
environment then arranged to translate references to the label name to
the gensym name. Given that Lisp 1.5 implementations didn't have lexical
scoping, this was a hell of a trick and it wasn't always clear cut what
was actually going on.
--
Jeff Barnett
Nils M Holm
2020-10-06 09:40:14 UTC
Permalink
Post by Jeff Barnett
Well some Lisp 1.5 implementations had a "label" form which was used as
(LABEL FOO (LAMBDA (X Y Z) ... (FOO A B C) ...))
I am doing some extensive research on this for my upcoming book on
the history and interpretation and compilation of mininal LISP.

LABEL can easily be emulated (modulo exact semantics due to lexical
scoping) in COMMON LISP:

; LISP 1.5 ; COMMON LISP
(LABEL FOO (LABELS
(LAMBDA (X) ((FOO (X)
(COND ((NULL X) (QUOTE BAR)) (COND ((NULL X) (QUOTE BAR))
(T (FOO (CDR X)))))) (T (FOO (CDR X))))))
(FUNCTION FOO))

Indeed the mechanism used in LISP 1.5 was pretty clever. LABEL inserted
a copy of its own definition into the environment before applying the
function contained in it to some values.
Post by Jeff Barnett
However, I don't clearly
remember two things about this: 1) Could a nested lambda see the outer
label name?
According to the specification in the LISP 1.5 manual (Appendix B, page
71), it should. However, this is the same specification that also claims
that LISP 1.5 does lexical scoping via FUNARG, so I tried it in
Paul Pierce's s709 emulator with the 1960-03-01 LISP tape, and indeed,

(LABEL FOO (LAMBDA (X) (COND ((ATOM X) X) (T (MAPCAR
(QUOTE (LAMBDA (X) (CONS (QUOTE 1) (FOO X)))) X)))))
((A B C D E))

evaluates to ((1 . A) (1 . B) (1 . C) (1 . D) (1 . E))
Post by Jeff Barnett
and 2) Did the label name block an outer global function
and, if so, how and when?
No, it does not:

DEFINE (( (FOO (LAMBDA (X) (QUOTE NOPE))) ))

(LABEL FOO (LAMBDA (X) (COND ((NULL X) NIL)
(T (FOO (CDR (PRINT X))))))) ((A B C D E)) ==> NOPE

This is compatible with the specification, which says that LABEL
binds functions in the A-list, but functions are looked up in the
EXPR property first.
Post by Jeff Barnett
The implementation usually compiled the lambda
expression using a gensym name and put the code in the outer global
environment then arranged to translate references to the label name to
the gensym name. Given that Lisp 1.5 implementations didn't have lexical
scoping, this was a hell of a trick and it wasn't always clear cut what
was actually going on.
--
Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
Jeff Barnett
2020-10-06 23:49:26 UTC
Permalink
Post by Nils M Holm
Post by Jeff Barnett
Well some Lisp 1.5 implementations had a "label" form which was used as
(LABEL FOO (LAMBDA (X Y Z) ... (FOO A B C) ...))
I am doing some extensive research on this for my upcoming book on
the history and interpretation and compilation of mininal LISP.
LABEL can easily be emulated (modulo exact semantics due to lexical
; LISP 1.5 ; COMMON LISP
(LABEL FOO (LABELS
(LAMBDA (X) ((FOO (X)
(COND ((NULL X) (QUOTE BAR)) (COND ((NULL X) (QUOTE BAR))
(T (FOO (CDR X)))))) (T (FOO (CDR X))))))
(FUNCTION FOO))
Indeed the mechanism used in LISP 1.5 was pretty clever. LABEL inserted
a copy of its own definition into the environment before applying the
function contained in it to some values.
Post by Jeff Barnett
However, I don't clearly
remember two things about this: 1) Could a nested lambda see the outer
label name?
According to the specification in the LISP 1.5 manual (Appendix B, page
71), it should. However, this is the same specification that also claims
that LISP 1.5 does lexical scoping via FUNARG, so I tried it in
Paul Pierce's s709 emulator with the 1960-03-01 LISP tape, and indeed,
(LABEL FOO (LAMBDA (X) (COND ((ATOM X) X) (T (MAPCAR
(QUOTE (LAMBDA (X) (CONS (QUOTE 1) (FOO X)))) X)))))
((A B C D E))
evaluates to ((1 . A) (1 . B) (1 . C) (1 . D) (1 . E))
Post by Jeff Barnett
and 2) Did the label name block an outer global function
and, if so, how and when?
DEFINE (( (FOO (LAMBDA (X) (QUOTE NOPE))) ))
(LABEL FOO (LAMBDA (X) (COND ((NULL X) NIL)
(T (FOO (CDR (PRINT X))))))) ((A B C D E)) ==> NOPE
This is compatible with the specification, which says that LABEL
binds functions in the A-list, but functions are looked up in the
EXPR property first.
That's interesting. I notice that you are talking as if there were a
single Lisp 1.5 semantics in some places but not in others. There were
several in the 1960s and 1970s and even into the 1980s, and there was no
agreement among implementers on basic semantics, particularly as to
scope in interesting situations. The lexical scope enjoyed in Common
Lisp was like a breath of fresh air; both to programmers and a batch of
computational linguist as in folks interested in program language
semantics).

If you haven't already, visit

http://www.softwarepreservation.org/projects/LISP/
Post by Nils M Holm
Post by Jeff Barnett
The implementation usually compiled the lambda
expression using a gensym name and put the code in the outer global
environment then arranged to translate references to the label name to
the gensym name. Given that Lisp 1.5 implementations didn't have lexical
scoping, this was a hell of a trick and it wasn't always clear cut what
was actually going on.
--
Jeff Barnett
Nils M Holm
2020-10-07 13:46:27 UTC
Permalink
[...] I notice that you are talking as if there were a
single Lisp 1.5 semantics in some places but not in others. There were
several in the 1960s and 1970s and even into the 1980s, and there was no
agreement among implementers on basic semantics, particularly as to
scope in interesting situations. The lexical scope enjoyed in Common
Lisp was like a breath of fresh air; both to programmers and a batch of
computational linguist as in folks interested in program language
semantics).
I am well aware of this! However, I do not want to go down that rabbit
hole in my book, so I am concentrating on LISP 1, 1.5, 1.6, and MACLISP,
which seem to be pretty consistent, except for some details like mixing
compiled and interpreted code and, in particular, visibility of bindings
between them.

The issues that arise out of dynamic scoping are a central part of the
book. Indeed lexical scope was a great improvement! I have experienced
the transition myself when moving from Franz LISP to Scheme.
If you haven't already, visit
http://www.softwarepreservation.org/projects/LISP/
I have, multiple times, and it is an invaluable resource! Thanks!
--
Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
Barry Margolin
2020-10-08 14:38:12 UTC
Permalink
Post by Nils M Holm
Post by Kaz Kylheku
Post by Arseny Slobodyuk
It's very exciting but I believe is just another phrasing of the fact
Note that "not evaluating its argument" is just what the operator
doesn't do; it doesn't inform us what the operator *does*.
Interestingly, in early LISP these two interpretations were exactly
the same. FUNCTION was merely an alias of QUOTE in LISP 1.5, LISP 1.6,
and (early?) MACLISP, so "what it does" and "what it does not do"
basically said the same thing! (LISP 1 was a LISP-1, so it did not
have a FUNCTION form).
This equivalence worked in those languages because there was no lexical
namespace for functions. The function binding was simply a property of
the symbol, and using the symbol in a function context caused the
interpreter to look up this property.
--
Barry Margolin, ***@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Nils M Holm
2020-10-08 15:27:23 UTC
Permalink
Post by Barry Margolin
Post by Nils M Holm
Interestingly, in early LISP these two interpretations were exactly
the same. FUNCTION was merely an alias of QUOTE in LISP 1.5, LISP 1.6,
and (early?) MACLISP, so "what it does" and "what it does not do"
basically said the same thing! (LISP 1 was a LISP-1, so it did not
have a FUNCTION form).
This equivalence worked in those languages because there was no lexical
namespace for functions. The function binding was simply a property of
the symbol, and using the symbol in a function context caused the
interpreter to look up this property.
But expressins like

(MAPLIST (QUOTE CAR) (QUOTE (1 2 3)))

still work in Common Lisp! However, the mechanism that is at work here
is certainly a different one. Does FUNCALL look up the function binding
of CAR?
--
Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
smh
2020-10-08 18:22:53 UTC
Permalink
Post by Nils M Holm
However, the mechanism that is at work here
is certainly a different one. Does FUNCALL look up the function binding
of CAR?
This question is so easily answered by reference to the easily-available language standard. Look up FUNCALL, which will lead you to the definition of FUNCTION DESIGNATOR, which treatment is quite different from what the FUNCTION special operator does with a FUNCTION NAME symbol argument or a symbol appearing in the car or a function call form.
Nils M Holm
2020-10-09 11:12:50 UTC
Permalink
Post by smh
Post by Nils M Holm
However, the mechanism that is at work here
is certainly a different one. Does FUNCALL look up the function binding
of CAR?
This question is so easily answered by reference to the easily-available
language standard. [...]
Sure, but sometimes you get a more insightful answer by asking.
--
Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org
Barry Margolin
2020-10-11 23:34:40 UTC
Permalink
Post by Nils M Holm
Post by Barry Margolin
Post by Nils M Holm
Interestingly, in early LISP these two interpretations were exactly
the same. FUNCTION was merely an alias of QUOTE in LISP 1.5, LISP 1.6,
and (early?) MACLISP, so "what it does" and "what it does not do"
basically said the same thing! (LISP 1 was a LISP-1, so it did not
have a FUNCTION form).
This equivalence worked in those languages because there was no lexical
namespace for functions. The function binding was simply a property of
the symbol, and using the symbol in a function context caused the
interpreter to look up this property.
But expressins like
(MAPLIST (QUOTE CAR) (QUOTE (1 2 3)))
still work in Common Lisp! However, the mechanism that is at work here
is certainly a different one. Does FUNCALL look up the function binding
of CAR?
Yes, it does, but it's limited to the global binding. If you want to get
a lexical binding, you have to use the FUNCTION special operator.
--
Barry Margolin, ***@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Zyni Moë
2020-10-06 10:39:53 UTC
Permalink
Post by Arseny Slobodyuk
It's very exciting but I believe is just another phrasing of the fact
that it's non-evaluating its argument.
Is not. No special operator evaluates all its args: is why they are
special. QUOTE does not evaluate its argument, but QUOTE is not tool to
access namespace of functions: FUNCTION is.

In fact FUNCTION and FUNCALL are the two operators which define a Lisp-2: a
Lisp-1 needs neither. FUNCALL does not need to be syntactically special,
only semantically: all function calls (x ...) can be made into (funcall
(function x) ...) except (funcall ...) which can't.
Wish people would stop quoting ancient text which is full of errors.
Post by Arseny Slobodyuk
But what message is passed in the Kaz's case? "You know what to do, do it"?
Obviously if message to indexable object is index then answer is element at
that index. Any object can be message, is up to receiver to define how it
is handled.
--
the small snake
Kaz Kylheku
2020-10-06 16:29:23 UTC
Permalink
Post by Zyni Moë
Post by Arseny Slobodyuk
It's very exciting but I believe is just another phrasing of the fact
that it's non-evaluating its argument.
Is not. No special operator evaluates all its args: is why they are
Counterexample:

(if test consequent)

all arguments of if are ordinary expressions. In a two-argument if, if
the test is true, all arguments are evaluated.

Another counterexample:

(time expression)

This evaluates its argument, measuring how much time that takes. Though
documented as a macro operator in Common Lisp, it could be a special
operator.

Another macro counterexample:

(ignore-errors form ...)
Post by Zyni Moë
special. QUOTE does not evaluate its argument, but QUOTE is not tool to
access namespace of functions: FUNCTION is.
This is because FUNCTION evaluates its argument: it evaluates a symbol
against the function namespace, rather than the variable namespace.
Post by Zyni Moë
In fact FUNCTION and FUNCALL are the two operators which define a Lisp-2: a
Lisp-1 needs neither.
A Lisp-1 certainly needs FUNCTION, or something like it, if it supports
compound function names. Suppose that you have a Lisp-1 which lets you
do this:

;; "getter-setter" pair

(define foo (obj arg)
(access-foo obj arg))

(define (set foo) (obj arg new-value)
(store-foo obj arg new-value))

Such that now you can do things like:

(foo x) ;; access (foo x)
(set (foo x) 42) ;; put new value into (foo x)

In this dialect, how do you get the (set foo) function as an object?

There could be a hack that (set foo) actually does that (i.e. when the
second argument of the set operator is absent, it produces the
function).

If you don't want such a hack, which could be for very good reasons, the
next available possibility is a dedicated operator: (function (set
foo)). This says, "please evaluate (set foo) as a function name, and
not as an invocation of the set operator".
Zyni Moë
2020-10-06 17:10:27 UTC
Permalink
Post by Kaz Kylheku
[...]
Special operators do not follow usual evaluation rules, is point. CL is
applicative-order language, special forms are not applicative-order, as if
they were they would mot be special forms, but ordinary functions. That is
what I meant by 'not evaluating their arguments'. Sorry, assumed that was
obvious.

Think we agree that a version of FUNCTION which was applicative order would
not be useful: you would need other operator, call it FN say, which did
not.
Post by Kaz Kylheku
A Lisp-1 certainly needs FUNCTION, or something like it, if it supports
compound function names.
But it does not if it does not. A Lisp-2 does, even if it does not.

I think we argue over tiny worms here. We agree that FUNCTION is how you
access the function namespace, and that it should not (can not) use
applicative-order for its evaluation I think.
--
the small snake
none) (albert
2020-10-08 16:42:40 UTC
Permalink
Post by Kaz Kylheku
Post by Zyni Moë
Post by Arseny Slobodyuk
It's very exciting but I believe is just another phrasing of the fact
that it's non-evaluating its argument.
Is not. No special operator evaluates all its args: is why they are
(if test consequent)
all arguments of if are ordinary expressions. In a two-argument if, if
the test is true, all arguments are evaluated.
So if the test is falls, not all arguments are evaluated.
Perfect counterexample, not!
Post by Kaz Kylheku
(time expression)
This evaluates its argument, measuring how much time that takes. Though
documented as a macro operator in Common Lisp, it could be a special
operator.
(ignore-errors form ...)
Post by Zyni Moë
special. QUOTE does not evaluate its argument, but QUOTE is not tool to
access namespace of functions: FUNCTION is.
This is because FUNCTION evaluates its argument: it evaluates a symbol
against the function namespace, rather than the variable namespace.
Post by Zyni Moë
In fact FUNCTION and FUNCALL are the two operators which define a Lisp-2: a
Lisp-1 needs neither.
A Lisp-1 certainly needs FUNCTION, or something like it, if it supports
compound function names. Suppose that you have a Lisp-1 which lets you
;; "getter-setter" pair
(define foo (obj arg)
(access-foo obj arg))
(define (set foo) (obj arg new-value)
(store-foo obj arg new-value))
(foo x) ;; access (foo x)
(set (foo x) 42) ;; put new value into (foo x)
In this dialect, how do you get the (set foo) function as an object?
There could be a hack that (set foo) actually does that (i.e. when the
second argument of the set operator is absent, it produces the
function).
If you don't want such a hack, which could be for very good reasons, the
next available possibility is a dedicated operator: (function (set
foo)). This says, "please evaluate (set foo) as a function name, and
not as an invocation of the set operator".
My interpretation of a "special" function. It gets all its arguments
unevaluated, and decides for itself what to do with it.
In rare cases that may mean evalute them all.

Groetjes Albert
--
This is the first day of the end of your life.
It may not kill you, but it does make your weaker.
If you can't beat them, too bad.
***@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
Kaz Kylheku
2020-10-03 01:33:33 UTC
Permalink
Post by none) (albert
Post by Arseny Slobodyuk
Wow, you certainly gave it a go! It looked much smarter when I started
to learn lisp!
BTW, you mentioned clisp and I recalled that clisp distro has a similar
file named LISP-tutorial.txt I believe it contains much less typos.
I might be mixed those tutorials in my memory into a single one.
Thanks. That tutorial is useful and probably more reliable.
It is more elaborate on the basics, and less on the more advanced
topics.
Post by Arseny Slobodyuk
Post by none) (albert
13
(eval ''boing)
;'boing
in clisp this results in
; boing
Am I correct that first ''boing is evaluated giving 'boing
then passed to eval giving boing ?
This is (eval (quote (quote boing))). eval is a function, and
so its argument expression (quote (quote boing)) is evaluated
to calculate the argument value. That argument value is therefore
(quote boing): a two-element list of symbols representing
a quote expression. That one is evaluated within eval, which
returns the resulting value: the symbol boing.

.
Post by none) (albert
Post by Arseny Slobodyuk
Post by none) (albert
17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION LAMBDA (N) (* N 10)>
The modern way is #'(lambda (n) (* n 10))
That notation is there too, as a test.
The official way seems to be
(function (lambda (n) (*n 10))
and the #' looks like a superfluous idosyncracy to me.
The #' and function are equivalent. #'X means (function X).

This is a Common Lisp thing.

In Common Lisp, (function ...) is a special form. It must be
used in order to obtain functional value from the funtion name
as in (function cons) or a lambda expression as above.

In various historic dialects of Lisp, this is not so; we often
find a straightforward, sane lambda special form which allows
the programmer to just write (lambda (n) (* n 10)).

You are seeing this in Scheme, which has a "special procedure"
called lambda.

In order for better compatibility with Lisp dialects that
have sane treatment of lambda in the syntax, Common Lisp provides a
macro called lambda. Yes, a macro.

The Common Lisp lambda macro rewrites (lambda (...) ...)
to (function (lambda (...))).

[1]> (macroexpand '(lambda (x) y))
#'(LAMBDA (X) Y) ;
T

Since the macro exists as a standard language feature, it behooves us to
use it instead of peppering the code with unnecessary #' garnishing.
--
TXR Programming Language: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
none) (albert
2020-10-03 12:38:03 UTC
Permalink
Post by Kaz Kylheku
Post by none) (albert
Post by Arseny Slobodyuk
Wow, you certainly gave it a go! It looked much smarter when I started
to learn lisp!
BTW, you mentioned clisp and I recalled that clisp distro has a similar
file named LISP-tutorial.txt I believe it contains much less typos.
I might be mixed those tutorials in my memory into a single one.
Thanks. That tutorial is useful and probably more reliable.
It is more elaborate on the basics, and less on the more advanced
topics.
Post by Arseny Slobodyuk
Post by none) (albert
13
(eval ''boing)
;'boing
in clisp this results in
; boing
Am I correct that first ''boing is evaluated giving 'boing
then passed to eval giving boing ?
This is (eval (quote (quote boing))). eval is a function, and
so its argument expression (quote (quote boing)) is evaluated
to calculate the argument value. That argument value is therefore
(quote boing): a two-element list of symbols representing
a quote expression. That one is evaluated within eval, which
returns the resulting value: the symbol boing.
.
Post by none) (albert
Post by Arseny Slobodyuk
Post by none) (albert
17
(lambda (n) (* n 10))
;Error: undefined function lambda
in clisp this is
#<FUNCTION LAMBDA (N) (* N 10)>
The modern way is #'(lambda (n) (* n 10))
That notation is there too, as a test.
The official way seems to be
(function (lambda (n) (*n 10))
and the #' looks like a superfluous idosyncracy to me.
The #' and function are equivalent. #'X means (function X).
This is a Common Lisp thing.
In Common Lisp, (function ...) is a special form. It must be
used in order to obtain functional value from the funtion name
as in (function cons) or a lambda expression as above.
In various historic dialects of Lisp, this is not so; we often
find a straightforward, sane lambda special form which allows
the programmer to just write (lambda (n) (* n 10)).
You are seeing this in Scheme, which has a "special procedure"
called lambda.
In order for better compatibility with Lisp dialects that
have sane treatment of lambda in the syntax, Common Lisp provides a
macro called lambda. Yes, a macro.
The Common Lisp lambda macro rewrites (lambda (...) ...)
to (function (lambda (...))).
[1]> (macroexpand '(lambda (x) y))
#'(LAMBDA (X) Y) ;
T
Since the macro exists as a standard language feature, it behooves us to
use it instead of peppering the code with unnecessary #' garnishing.
I don't quite follow your reasoning, and just calling clisp's treatment
of lambda sane does nothing to convince.
Count me firmly in the scheme camp.
Post by Kaz Kylheku
--
Groetjes Albert
--
This is the first day of the end of your life.
It may not kill you, but it does make your weaker.
If you can't beat them, too bad.
***@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
none) (albert
2020-09-29 12:06:20 UTC
Permalink
Post by Ishaan
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some
help with lisp.
Post by Ishaan
I've been trying to learn the basics for the past few days and
everything about it confuses me. I'm ok at javascript and python, but
this really trips me up. I just can't anything to work, and I've never
been so frustrated at a computer. Also how long should it take to be
able to write decent programs in lisp and descendent dialects?
I recommend "Lisp Notes" https://www.cs.ccu.edu.tw/~dan/lispnotes.txt to
everybody. It never works out but anyway. I think it contains just a
necessary amount to feel the spirit. It is an excerpt from the
D.Touretzky's "A gentle introduction to symbolics computation".
That is really great. E.g. my first question with clisp was
(See an other thread) what char's can I use. That is one of the
first issues treated. He should however have mentionned that
not all functions have their list elements evaluated, I mean
a hint/warning that special functions exist.

Groetjes Albert
--
This is the first day of the end of your life.
It may not kill you, but it does make your weaker.
If you can't beat them, too bad.
***@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
luserdroog
2020-09-29 15:51:27 UTC
Permalink
Post by none) (albert
Post by Ishaan
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some
help with lisp.
Post by Ishaan
I've been trying to learn the basics for the past few days and
everything about it confuses me. I'm ok at javascript and python, but
this really trips me up. I just can't anything to work, and I've never
been so frustrated at a computer. Also how long should it take to be
able to write decent programs in lisp and descendent dialects?
I recommend "Lisp Notes" https://www.cs.ccu.edu.tw/~dan/lispnotes.txt to
everybody. It never works out but anyway. I think it contains just a
necessary amount to feel the spirit. It is an excerpt from the
D.Touretzky's "A gentle introduction to symbolics computation".
That is really great. E.g. my first question with clisp was
(See an other thread) what char's can I use. That is one of the
first issues treated. He should however have mentionned that
not all functions have their list elements evaluated, I mean
a hint/warning that special functions exist.
Groetjes Albert
https://www.nhplace.com/kent/Papers/Special-Forms.html

hth
Manfred Bergmann
2020-09-26 12:50:56 UTC
Permalink
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
If you are new to Emacs AND Common Lisp, then you might have a quite steep learning curve.

There are a few YouTube video channels aimed at beginners, like this:
https://www.youtube.com/channel/UC1J47RqBfY6VgLUZ5YSYkqw

This guy (which appears to be me :) also has a few Common Lisp videos:
https://www.youtube.com/channel/UC4Vt1YZhIVWj_rZSCyxG5DQ
Post by Ishaan
Also how long should it take to be able to write decent programs
That depends. The language IMO is not the problem.
There are just a few concept you have to understand as well as the API and available functions of Common Lisp.

Do you know the Common Lisp Cookbook?
https://lispcookbook.github.io/cl-cookbook/
Post by Ishaan
in lisp and descendent dialects
What are those?

Racket Scheme is quite nice. But it's a Scheme and not a decendent.
There is also Gerbil Scheme which seems to be a bit more 'modern' (https://cons.io).
But Common Lisp is as modern as you could imagine.

There are also Lisps on the Erlang VM like LFE:
https://lfe.io

You don't say what you are actually struggling with?


Manfred
Manfred Bergmann
2020-09-26 13:02:37 UTC
Permalink
Btw: there is also SLIME for Atom (https://atom.io/packages/slima), if you are unfamiliar to Emacs (though learning Emacs is a big plus generally).

If you know Eclipse there is a plugin:
https://ragnaroek.github.io/dandelion/

There is also a LispWorks Personal edition which has with a graphical IDE:
http://www.lispworks.com/downloads/index.html



Manfred
Post by Manfred Bergmann
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
If you are new to Emacs AND Common Lisp, then you might have a quite steep learning curve.
https://www.youtube.com/channel/UC1J47RqBfY6VgLUZ5YSYkqw
https://www.youtube.com/channel/UC4Vt1YZhIVWj_rZSCyxG5DQ
Post by Ishaan
Also how long should it take to be able to write decent programs
That depends. The language IMO is not the problem.
There are just a few concept you have to understand as well as the API and available functions of Common Lisp.
Do you know the Common Lisp Cookbook?
https://lispcookbook.github.io/cl-cookbook/
Post by Ishaan
in lisp and descendent dialects
What are those?
Racket Scheme is quite nice. But it's a Scheme and not a decendent.
There is also Gerbil Scheme which seems to be a bit more 'modern' (https://cons.io).
But Common Lisp is as modern as you could imagine.
https://lfe.io
You don't say what you are actually struggling with?
Manfred
Ishaan
2020-09-28 19:43:49 UTC
Permalink
Post by Manfred Bergmann
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
If you are new to Emacs AND Common Lisp, then you might have a quite steep learning curve.
https://www.youtube.com/channel/UC1J47RqBfY6VgLUZ5YSYkqw
https://www.youtube.com/channel/UC4Vt1YZhIVWj_rZSCyxG5DQ
Post by Ishaan
Also how long should it take to be able to write decent programs
That depends. The language IMO is not the problem.
There are just a few concept you have to understand as well as the API and available functions of Common Lisp.
Do you know the Common Lisp Cookbook?
https://lispcookbook.github.io/cl-cookbook/
Post by Ishaan
in lisp and descendent dialects
What are those?
Racket Scheme is quite nice. But it's a Scheme and not a decendent.
There is also Gerbil Scheme which seems to be a bit more 'modern' (https://cons.io).
But Common Lisp is as modern as you could imagine.
https://lfe.io
You don't say what you are actually struggling with?
Manfred
I think I'm mostly struggling with emacs and getting everything set up, but that's most languages, I think.
Thanks for recommending the Lisp Cookbook and the YouTube videos, I'll be sure to use them thoroughly.
And I think I should have just said "dialects" instead of "descendent dialects".

Thanks for the help!
Ishaan
Kaz Kylheku
2020-09-28 20:20:26 UTC
Permalink
Post by Ishaan
Post by Manfred Bergmann
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
If you are new to Emacs AND Common Lisp, then you might have a quite steep learning curve.
https://www.youtube.com/channel/UC1J47RqBfY6VgLUZ5YSYkqw
https://www.youtube.com/channel/UC4Vt1YZhIVWj_rZSCyxG5DQ
Post by Ishaan
Also how long should it take to be able to write decent programs
That depends. The language IMO is not the problem.
There are just a few concept you have to understand as well as the API and available functions of Common Lisp.
Do you know the Common Lisp Cookbook?
https://lispcookbook.github.io/cl-cookbook/
Post by Ishaan
in lisp and descendent dialects
What are those?
Racket Scheme is quite nice. But it's a Scheme and not a decendent.
There is also Gerbil Scheme which seems to be a bit more 'modern' (https://cons.io).
But Common Lisp is as modern as you could imagine.
https://lfe.io
You don't say what you are actually struggling with?
Manfred
I think I'm mostly struggling with emacs and getting everything set up, but that's most languages, I think.
Thanks for recommending the Lisp Cookbook and the YouTube videos, I'll be sure to use them thoroughly.
And I think I should have just said "dialects" instead of "descendent dialects".
LIsp does not require emacs. You can do the exercises with your favorite
editor. Some open source Lisps don't have a good interactive mode "out
of the box" with history recall and editing; they rely on an environment
like Emacs to provide it. However, there is a utility called "rlwrap"
(readline wrapper) that you can install in any major GNU/Linux distro
easily. It provides an interactive editing mode with persistent history
around any program. Completion won't be there, though, unless you
program it yourself. One Common Lisp implementation that has readline
built-in is CLISP. It is good for learning, if you just want to focus on
Lisp and nothing else.
--
TXR Programming Lanuage: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
Helmut Eller
2020-09-26 14:27:19 UTC
Permalink
Post by Ishaan
I've been trying to learn the basics for the past few days and
everything about it confuses me.
The basics of Lisp are the functions READ, EVAL and PRINT. Once you
have a good grasp of those, everything else is pretty easy. And the
beauty of Lisp is that a basic version of EVAL requires less than a
page.

Helmut
Stefan Monnier
2020-09-26 22:48:43 UTC
Permalink
Post by Helmut Eller
Post by Ishaan
I've been trying to learn the basics for the past few days and
everything about it confuses me.
The basics of Lisp are the functions READ, EVAL and PRINT.
I can agree with that when it comes to Lisp's implementation/internals,
but for a Lisp user, they're functions that are rarely used.


Stefan
Barry Margolin
2020-09-26 21:00:26 UTC
Permalink
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything
about it confuses me. I'm ok at javascript and python, but this really trips
me up. I just can't anything to work, and I've never been so frustrated at a
computer. Also how long should it take to be able to write decent programs in
lisp and descendent dialects?
If you understand JavaScript and Python, you really should be able to
pick up Lisp. The syntax is very different, but they pretty much adopted
Lisp's concepts of variables and data.
--
Barry Margolin, ***@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Azathoth Hastur
2020-10-13 23:00:00 UTC
Permalink
Post by Ishaan
Hi,
I'm a high school student interested in programming and I need some help with lisp.
I've been trying to learn the basics for the past few days and everything about it confuses me. I'm ok at javascript and python, but this really trips me up. I just can't anything to work, and I've never been so frustrated at a computer. Also how long should it take to be able to write decent programs in lisp and descendent dialects?
how do you build big apps tha trequire 100 boxes of power in lisp?
is there anything like scylladb.com or timescaledb?
or can naviserver and postgresql kick lisp ass every time esp on archlinux?
Loading...