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

[ASL] Value of set! #162

Open
a11ce opened this issue Nov 12, 2021 · 1 comment
Open

[ASL] Value of set! #162

a11ce opened this issue Nov 12, 2021 · 1 comment

Comments

@a11ce
Copy link

a11ce commented Nov 12, 2021

The value of calling set! appears to be (some form of) void:

> (define x 1)
> (set! x 2)
(void)

but doesn't behave as void or (void):

> (void? (set! x 3))
#false
> ((set! x 3))
function call: expected a function after the open parenthesis, but received (void)

This is causing confusion for students because they have to use something like (begin (set! x y) (void)) even though it looks unnecessary.

@a11ce
Copy link
Author

a11ce commented Nov 13, 2021

This looks like the same issue as #21. Here is an abridged concrete example from a course:

(define (evaluate-complex expr dict)
  ...
  [(eq? operator 'define)
           (begin (set! dictionary
                        (make-binding (second exp)
                                      (evaluate (third exp)
                                                d)
                                      dictionary))
                  (void))]
  ...)

(check-satisfied (evaluate '(define a 1)
                           dictionary)
                 void?)

Having set! (etc.) evaluate such that (void? (set! x 1)) may be easier in this case, but if that's unacceptable (per the last comment on #21), it should be explained somewhere that (void) (the output of set! in the REPL) is not the same as (void) (which produces a void value).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant