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

Support time-related primitives #166

Open
j-hui opened this issue May 19, 2023 · 0 comments
Open

Support time-related primitives #166

j-hui opened this issue May 19, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed type system

Comments

@j-hui
Copy link
Contributor

j-hui commented May 19, 2023

We should be able to query the current time and time a scheduled variable was last-updated. In fact, ssm-runtime already supports this, and codegen even has bindings for it. I tried hacking this in with 072fb9a (for now and last, whose syntax is prefix @@) and 152d994 (adding in Time as an alias for U64).

But there are several problems, leading me to remove these features from the scanner in 11752b8:

  • Timestamps cause mad leaks. This is because they are 64-bit values and are stored on the heap. Reading them causes allocation, and for some reason they aren't being cleaned up properly.
  • We can't do any kind of arithmetic or comparisons with time. Arithmetic operators like +, -, <, and == are hard-coded as I32 -> I32 -> I32. To support time arithmetic, we would need them to be aware of U64 somehow. This involves type classes or some other kind of overloading, which we're not ready for. We would also need to do codegen for them differently because we would need to read the value out of the heap using ssm_time_read() rather than ssm_unmarshal().
  • We can't even "read" the time. An easy hack out of the above issue is to add primitives to read the lower and upper 32 bits out of the 64-bit timestamp, using ssm_time_read(), but we would need syntax for this.
@j-hui j-hui added enhancement New feature or request help wanted Extra attention is needed type system labels May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed type system
Projects
None yet
Development

No branches or pull requests

1 participant