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

:merge can have side effects by calling a function with a :default #102

Closed
rtjoa opened this issue Jan 31, 2023 · 1 comment
Closed

:merge can have side effects by calling a function with a :default #102

rtjoa opened this issue Jan 31, 2023 · 1 comment

Comments

@rtjoa
Copy link
Contributor

rtjoa commented Jan 31, 2023

Possibly a non-issue (there's no bug), but it can lead to some spooky behavior.

In the below example, repeatedly setting bar, even though its table never changes, causes a feedback loop.

(function foo (i64) i64 :default 0)

(function bar () i64 :merge (min (foo new) 0))

(set (bar) 1)
(set (bar) 2)

(rule ((= f (foo x)))
      ((set (bar) (+ x 1))))


(print bar)      ; (bar) -> 0
(run 100)
(print bar)      ; (bar) -> 0
(print-size foo) ; Function foo has size 101
@yihozhang
Copy link
Collaborator

Subsumed by #421

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