-
Notifications
You must be signed in to change notification settings - Fork 11
[ENG-8] Add metadata()
#124
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
base: main
Are you sure you want to change the base?
Conversation
4b3aead
to
a861dc4
Compare
|
||
**String Representation**: | ||
Physical values maintain lossless string conversion, preserving original units and tolerances. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also add spec for metadata here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
let list_values = input_values | ||
.iter() | ||
.map(|input_value| input_value.to_value(eval, None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we have types where expected_typ
is needed (e.g. enums, records, interfaces)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find a way to convert those types to values without explicitly requiring the type to be provided at the call site. There's no easy way to extract + carry the necessary type information in Rust.
Maybe we can have an optional type hint argument? e.g. metadata.get(EnumTy)
. It's a bit awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to get simple records and enums sorta working by hacking around in starlark-rust, but it was very brittle, and still failed on stuff like records containing enums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok to say they are not supported right now especially now with native units — what's the behavior if you try to construct a metadata container of type enum(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can construct and push values into a metadata container with enum()
. On get()
, list()
, it'll fail with "enum input requires expected_typ".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just disallow building a container with unsupported types for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
fn get_attr(&self, attribute: &str, heap: &'v Heap) -> Option<Value<'v>> { | ||
match attribute { | ||
"push" => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very nice, I like this more than a bunch of global functions too
8d6dd95
to
1805622
Compare
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Signed-off-by: akhilles <[email protected]>
Example code: