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

eval* doesn't work properly in some cases #6

Closed
micuat opened this issue Jul 12, 2020 · 3 comments
Closed

eval* doesn't work properly in some cases #6

micuat opened this issue Jul 12, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@micuat
Copy link
Contributor

micuat commented Jul 12, 2020

https://glisp.app/commit:69e6023/?code_url=https%3A%2F%2Fgist.githubusercontent.com%2Fmicuat%2Fa267b81b207787cc5aaed6a7656d3c86%2Fraw%2F07698838c485e05cf236ed3b312db2768edae342%2Fclampbug.glisp

this doesn't work

(background "aliceblue")

(defvar x 100)
(defvar m0 0)
(defvar m1 100)
(transform (translate [(clamp x m0 m1) 74.29997253417969])
  (circle [0 0] 100)
)

this works

(background "aliceblue")

(defvar x 100)
(defvar m0 0)
(defvar m1 100)
(circle [(clamp x m0 m1) 74.29997253417969] 100)

it used to work - and currently broken on both master and develop branches

@baku89
Copy link
Owner

baku89 commented Jul 12, 2020

Thanks! It seems a much more urgent issue relating to the core evaluator.
Simpler code to reproduce the error:

(def x 10)

(transform (translate [x 0])
	(circle [0 0] 100))

@baku89
Copy link
Owner

baku89 commented Jul 12, 2020

It might be related to the special form eval* I made for Glisp. It's used inside a function/macro but evaluates an expression in scope called the function/macro unlike the normal eval which always evaluates in a global scope.

(defn test []
  (eval  '(prn "eval=" PI)) ; -> 3.14159
  (eval* '(prn "eval*=" PI))) ; -> 10

(def PI 10)
(test)

graphics/transform uses eval* inside its definition but it seems that the part inside eval* isn't bound to appropriate scope. I will try to resolve the problem as soon as possible.:)

@baku89 baku89 changed the title clamp broken inside translate? eval* doesn't work properly in some cases Jul 12, 2020
@baku89 baku89 added the bug Something isn't working label Jul 12, 2020
baku89 added a commit that referenced this issue Jul 19, 2020
@baku89
Copy link
Owner

baku89 commented Jul 19, 2020

Now your sketch would work :)

https://glisp.app/commit:198294a

@baku89 baku89 closed this as completed Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants