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

Chapter 6 Functions does not cover the situation of SetBang to a top-level defined function #128

Open
wine99 opened this issue Apr 1, 2022 · 1 comment

Comments

@wine99
Copy link

wine99 commented Apr 1, 2022

I am having trouble compiling programs like the below:

(define (f) : Integer 1)

(define (g) : Integer 42)

(begin (set! f g)
       (f))
(define (f) : Integer
  (begin (set! f g)
         (f)))

(define (g) : Integer 42)

(f)

I am following the course videos of 2020 but doing the assignments in the order that's presented in the book. The book introduces WhileLoop before Tuple and Function, which I think is nice since I can use Begin for the translation of Tuple. But when I come to Functions, the above examples upsets me. How can I compile the (set! f g)? Or should I just modify the type checker to forbid assignments to top-level defined functions?

@jsiek
Copy link
Collaborator

jsiek commented Sep 23, 2022

Good question! I hadn't thought about that. Let's forbid assignments to top-level defined functions.

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

2 participants