-
Notifications
You must be signed in to change notification settings - Fork 4
sprintf builtin #43
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
sprintf builtin #43
Conversation
anderseknert
left a comment
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.
There aren't that many tests for sprintf I'm afraid, as the OPA implementation simply mirrors the Go one. This was a mistake that has been problematic for all alternative implementations, as some things that Go's sprintf allows isn't feasible to implement in other languages. So the best thing is likely just to provide a best-effort implementation and to make it very clear that for anything non-trivial, the result is likely going to differ or not work at all.
The code looks good to me, but if you have somewhere where you've documented the supported built-is, it would be good to add a note about this there.
I see that it's already marked as "SDK-dependent": do you think we should do anything more?
right, done, thanks for the reminder! |
Readme.md
Outdated
| At the moment the following builtins are supported(and, by default, automatically injected when needed): | ||
|
|
||
| - String | ||
| - `sprintf` |
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.
Good! What I alluded to before is that it would be really good to mention here how this built-in won't behave exactly as sprintf in OPA, and should ideally only be used for simple operations, like %s, %d and such.
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.
Thanks for the feedback, I added a note, let me know how it reads 🙏
anderseknert
left a comment
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.
Great! Thanks 👍
Implement the
sprintfString builtin.@anderseknert I was unable to find testcases to cover the edge cases, do you have a link to spare?