convex
convex copied to clipboard
`schedule` cannot access local bindings
Given the current implementation, it is very easy reaching a situation where a scheduled transaction fails silently. Notably, the following example is counter-intuitive:
(let [x 42] (expand '(schedule 0 (def foo x))))
;; (schedule* 0 (compile (quote (def foo x))))
;; Of course, `x` is not defined anymore ; fails silently
I don't think this is fixable given that nothing is supposed to be evaluated in advance. Maybe we should remove schedule and use only explicit templating with schedule*.
Interesting. Making the schedule contain an anonymous function would potentially solve this, with a slight overhead.
Different from #353 but sounds like both should be coordinated.
I think I'd fancy templating more than a lambda:
- Don't have to store a closure (and pay for what you don't need)
- More in line with stuff like
deploy
Yeah you can template / build whatever you like with schedule*. The question I guess is how to make the helper macro schedule most intuitive.
If we want to preserve things like let bindings I think we have two main options:
- Use a lambda. Easy since the support for locals is already there, but does add a bit of cost
- Figure out some way to embed let bindings in
compileso that they don't need a lookup lookup later.
Option 2 is probably optimal, just needs a bit of careful though on the semantics. Should compile always inline let-bound variables, for example?