source-academy / sicp

XML sources of SICP and SICP JS, and support for generating Interactive SICP JS, PDF, e-book and comparison editions
https://sourceacademy.org/sicpjs
Creative Commons Attribution Share Alike 4.0 International
903 stars 119 forks source link

Relationship between is_variable or is_name? #283

Closed TobiasWrigstad closed 4 years ago

TobiasWrigstad commented 4 years ago

Which one to use and where?

martin-henz commented 4 years ago

There is no relationship.

is_variable is used in chapter 2 when dealing with symbolic computation. Here "variable" means what it means in math: a symbol that stands for many possible values. It's introduced here: https://source-academy.github.io/chapters/2.3.2.html#p7 These variables are used in representations of mathematical formulas, for example for symbolic differentiation.

is_name is used in chapter 4 when dealing with the syntax of Source. Our parser represents square; as a tagged list: ["name", ["square", null]] The function is_name checks the tag, see https://source-academy.github.io/chapters/4.1.2.html#p2

Regarding Source, the terminology that I would like to establish (and will read everything closely to make sure we achieve it) is:

So the string "square" above is a "symbol" as far as chapter 4 is concerned. Thus the function "symbol_of_name" in https://source-academy.github.io/chapters/4.1.2.html#p2

Previously I had "name_of_name" instead of "symbol_of_name", which is super-weird. The distinction between symbols and names comes very handy and improves clarity in chapter 4, I think.