Closed fanconnie closed 6 months ago
The time package is not in the Starlark standard. With the Rust Starlark it's very easy to define a Rust file that implements the time package, or whatever alternative API is desired. The suggestion would be trying that out in whatever project you need the time package first, and seeing if there is anything that makes it harder. Additionally, things like now
are probably not a good fit for a language like Starlark which aims to be deterministic.
The time package is not in the Starlark standard. With the Rust Starlark it's very easy to define a Rust file that implements the time package, or whatever alternative API is desired. The suggestion would be trying that out in whatever project you need the time package first, and seeing if there is anything that makes it harder. Additionally, things like
now
are probably not a good fit for a language like Starlark which aims to be deterministic.
The ability to parse time strings and compute intervals and durations is useful in many client applications that embed Starlark (e.g. as a query language or request filter). Of course the application must have the ability to control the clock (now
) for determinism. The Go impl has a nonstandard time package (see link above) that could be easily ported to the Rust and Java implementations, but I observed that it seems more Go-like than Python-like. It would be good for us to agree on a Starlark API for times and durations that doesn't have an inherent bias to any particular implementation language.
I think it would be weird if Starlark got a standard module including now
. But if there was an extension module specified by the Starlark spec, we'd endeavour to implement it to that spec. I don't think we (at Meta) have a massive use for time functions given the domains I am aware of us using Starlark, but I can see that it could be useful for some. Maybe the right place to discuss this further is https://github.com/bazelbuild/starlark?
I think it would be weird if Starlark got a standard module including
now
. But if there was an extension module specified by the Starlark spec, we'd endeavour to implement it to that spec. I don't think we (at Meta) have a massive use for time functions given the domains I am aware of us using Starlark, but I can see that it could be useful for some. Maybe the right place to discuss this further is https://github.com/bazelbuild/starlark?
The issue on the main repo was closed: https://github.com/bazelbuild/bazel/issues/19477, maybe start another?
@fanconnie - Bazel is for the functions available in Bazel. Bazelbuild/starlark is for changing the Starlark spec. They are heavily influenced by each other, but are separate.
Closing this since the right location is the upstream spec. We just follow that spec. Since additional functions can be mixed in by the user library, there's nothing stopping you from adding this to your Starlark Rust based interpreter.
Like Go version does: https://github.com/google/starlark-go/tree/master/lib/time