Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between value, variable, object, and name in the following expression?

(define size 2)

I'm using Structure and Interpretation of Computer Programs as a guide to teaching myself computer science, and while I enjoy the book as a reading experience, I've found the degree to which the author throws in terms without any explanation as to the nuances and differences between them pretty frustrating.

The author says the name and value in the example are size and 2 respectively but doesn't go into which part of the example is the variable or object. I'm super new to the subject and cannot tell if he is using terms interchangeably (ie value and variable).

like image 507
viracocha Avatar asked Oct 16 '22 12:10

viracocha


1 Answers

size is the name of the variable. A variable is a storage location with a name. There can also be storage locations that aren't variables. For instance (car foo) is an expression that returns the value stored in the first slot of a pair; the variable's value is the pair, but the first slot doesn't have a name, so it's not a variable.

In this context, "object" and "value" are equivalent. Value refers to the role that the object serves in the assignment expression.

like image 183
Barmar Avatar answered Dec 19 '22 23:12

Barmar