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 072fb9aa20796a7ac1243b19eee5e9d675ea3c41 (for now and last, whose syntax is prefix @@) and 152d9943365ce8bdee2e58eb2a0370bd53005c29 (adding in Time as an alias for U64).
But there are several problems, leading me to remove these features from the scanner in 11752b86f064484304a84c6943d1eb448b0423c1:
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.
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 072fb9aa20796a7ac1243b19eee5e9d675ea3c41 (for
now
andlast
, whose syntax is prefix@@
) and 152d9943365ce8bdee2e58eb2a0370bd53005c29 (adding inTime
as an alias forU64
).But there are several problems, leading me to remove these features from the scanner in 11752b86f064484304a84c6943d1eb448b0423c1:
+
,-
,<
, and==
are hard-coded asI32 -> I32 -> I32
. To support time arithmetic, we would need them to be aware ofU64
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 usingssm_time_read()
rather thanssm_unmarshal()
.ssm_time_read()
, but we would need syntax for this.