Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globals/Bindings: Fix description of REPL/SET in book #451

Open
yossigil opened this issue Aug 23, 2021 · 2 comments
Open

Globals/Bindings: Fix description of REPL/SET in book #451

yossigil opened this issue Aug 23, 2021 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@yossigil
Copy link
Collaborator

Observe that the list to support two kinds of set operations in the implementation of REPL. The book currently does not tell you how to solve the mystery of sets, in the REPL.

With the REPL, if you do a set within one function, this set is saved for the next iteration; if this was not the case, then the set function would be meaningless. A correct implementation of REPL requires that if you do a set deep inside a function; this set will remain in effect when the function returns. We cannot distinguish between a direct call

> (set ‘a 2)

and indirect call,

> (cond (
  ((set ‘a 2) t)
)

If we make the distinction, then the user will be confused. So, in the REPL, there are two kinds of SET. Global and local. Also, if the set operation is invoked indirectly, by a function that is defined in the library, then the SET must also prevail. We must have two kinds of SET in the REPL:
Global for setting variable, and local for making bindings.

The subtle issue of the difference between argument binding and global bindings. All SET operations in the book are local. The little lie is that function SET is used in the book to define functions such as QUOTE, NDEFUN, and LAMBDA. But, the book does not deal with issue of evaluating two expressions in sequence, preserving the SETs made in the first expression to the evaluation in the second expressions. As far as the book is concerned, there is no way to do so, since the implementation of the a-list in the book does not support a distinction
between local setting for binding, and global setting of variables.

This is not a serious issue, and the book is fine in describing the implementation of EVAL, but no the implementation of REPL.
But it should be made clear.

@yossigil yossigil self-assigned this Aug 23, 2021
@yossigil yossigil added the documentation Improvements or additions to documentation label Aug 23, 2021
@yossigil
Copy link
Collaborator Author

@DorYeheskel , @OfirMarkowitz1 : perhaps this will help in understanding

@yossigil
Copy link
Collaborator Author

#374 #452

@yossigil yossigil changed the title Fix description of REPL/SET Globals/Bindings: Fix description of REPL/SET in book Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant