(bind-val x float 100.0)
(bind-val y float 100.0)
(bind-val xspeed float 2.5)
(bind-val yspeed float 2.0)
(bind-func draw_frame
(let ((frame 0))
(lambda ()
;; draw background
(background 1.0 1.0 1.0)
;; update the ball position
(set! x (+ x xspeed))
(set! y (+ y yspeed))
(if (or (> x width) (< x 0.0))
(set! xspeed (* xspeed -1.0)))
(if (or (> y height) (< y 0.0))
(set! yspeed (* yspeed -1.0)))
;; draw the ball
(circle x y 48.0)
;; increment and end frame
(set! frame (+ frame 1)))))
(set! x 4.0)
stack-catch: ()
stack-catch: ()
set!: unbound variable:
Trace:
I vote for allowing mutation of bind-val'ed variables. Sure, insist on the type remaining the same, but is there any good reason to protect the values from change? Is is a caching efficiency thing?
--
You received this message because you are subscribed to the Google Groups "Extempore" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I vote for allowing mutation of bind-val'ed variables. Sure, insist on the type remaining the same, but is there any good reason to protect the values from change? Is is a caching efficiency thing?
(sys:load "libs/external/glfw3.xtm")
(bind-val width float 800.)
(bind-val height float 200.)
(bind-val window GLFWwindow*
(begin
(glfwSetErrorCallback (convert (get_native_fptr glfw_error_callback)))
(glfw_init_and_create_interaction_window (convert width) (convert height))))
(sys:load "libs/external/nanovg.xtm")
(bind-val vg NVGcontext* (nvg_create_context))
(bind-val pixel_ratio float (glfw_get_pixel_ratio window))
(setup_graphics 800. 200.)
Compiler Error cannot find variable pixel_ratio
Compiler Error cannot find symbol impc:aot:insert-globalvar-binding-details
--
You received this message because you are subscribed to the Google Groups "Extempore" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Can you please explain (call-as-xtlang) ?
If I understand correctly, its treating xtlang as data and asking the xtlang compiler to evaluate this code. But why?
In the case of (set! x 4.0) you are using it because set! is a scheme function to the compiler defaults to scheme?
Here's the context, I'm trying to make this code:(sys:load "libs/external/glfw3.xtm")
(bind-val width float 800.)
(bind-val height float 200.)
(bind-val window GLFWwindow*
(begin
(glfwSetErrorCallback (convert (get_native_fptr glfw_error_callback)))
(glfw_init_and_create_interaction_window (convert width) (convert height))))
(sys:load "libs/external/nanovg.xtm")
(bind-val vg NVGcontext* (nvg_create_context))
(bind-val pixel_ratio float (glfw_get_pixel_ratio window))into a function like this:(setup_graphics 800. 200.)Obviously, I can't wrap it in a function because you can't allocate global variables from within a bind-func. Plus, at the time of binding, many of the types used don't exist yet because the libs haven't been loaded yet.
Is a macro what I'm looking for? (I don't know macros yet) In OOP, this kind of thing would happen in a function in the top most class.