Discussion:
Beginner questions about *terminology* in Common Lisp....
(too old to reply)
c***@gmail.com
2020-05-19 01:59:17 UTC
Permalink
For following code:
(defun f (x) x)
(print (f 'k))

Is it correct to say when (f 'k ) is evaluated that......

1. The "value" of x is 'k? (with quote)

and

2. The "what x evaluates to" is k? (without quote so not equal to value!)

and finally,

3. The environment, when (f 'k) is evaluated, stores
"what x evaluates to" rather than the "value" of x which are NOT the
same?

Thanks!

Chris
Ben Bacarisse
2020-05-19 02:38:34 UTC
Permalink
Post by c***@gmail.com
(defun f (x) x)
(print (f 'k))
Is it correct to say when (f 'k ) is evaluated that......
1. The "value" of x is 'k? (with quote)
Not really, no. What happens is this:

A function binding for f is looked up and the function you defined is
found. Then, the arguments are evaluated. In this case, only one: 'k.
The value of the form 'k is the symbol k. In Lisp, symbols are one of
the primitive kinds of "things" like numbers, characters, strings, nil
and t.

No, with a function and its fully evaluated arguments, we call the
function. That involves binding x to the symbol k and evaluating the
function's body in this new environment. The body is just x which is
evaluated by looking for a binding for it. That bound value, the symbol
k, is returned from the function to become the argument to another
function: print.
Post by c***@gmail.com
and
2. The "what x evaluates to" is k? (without quote so not equal to value!)
and finally,
3. The environment, when (f 'k) is evaluated, stores
"what x evaluates to" rather than the "value" of x which are NOT the
same?
Unfortunately I can not work out what you are saying here. If what I
said above helps, maybe you can re-phrase any questions using more
standard terminology.
--
Ben.
c***@gmail.com
2020-05-19 03:00:16 UTC
Permalink
Post by Ben Bacarisse
The value of the form 'k is the symbol k.
Thanks! Is what you said above equivalent to saying that 'k evaluates to k? Does the word "value" always mean what something evaluates to?
Ben Bacarisse
2020-05-19 10:36:05 UTC
Permalink
Post by c***@gmail.com
Post by Ben Bacarisse
The value of the form 'k is the symbol k.
Thanks! Is what you said above equivalent to saying that 'k evaluates
to k?
Yes, provided you can be sure the listener (or reader) will know what
you mean. Names and the things they stand for are so often confused in
casual conversation that it helps to add explanatory words. Also, not
many languages have symbols, so even the basic concept can be initially
confusing.
Post by c***@gmail.com
Does the word "value" always mean what something evaluates to?
That's too close to philosophy for me!
--
Ben.
paul wallich
2020-05-20 01:13:32 UTC
Permalink
Post by Ben Bacarisse
Post by c***@gmail.com
Post by Ben Bacarisse
The value of the form 'k is the symbol k.
Thanks! Is what you said above equivalent to saying that 'k evaluates
to k?
Yes, provided you can be sure the listener (or reader) will know what
you mean. Names and the things they stand for are so often confused in
casual conversation that it helps to add explanatory words. Also, not
many languages have symbols, so even the basic concept can be initially
confusing.
And you have to be careful about how you speak because it's easy to mix
up you levels in ordinary conversion. For example, if at some previous
point I've bound (the symbol) k to (the number) 5, I might say
colloquially that at this point "k is 5". But that "is" is not
transitive, because the value of the form 'k is absolutely not (the
number) 5.

Which should be obvious but occasionally isn't.

paul

Loading...