-
Notifications
You must be signed in to change notification settings - Fork 237
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
callers std.thisFile #436
Comments
This is not a problem with lazy evaluation, it's a problem with referential transparency, purity and avoiding any implicit magic. The Do you plan to use it for providing some debugging info? Can you provide more details about the use case? |
this comes from here: jsonnet-libs/docsonnet#5 and problems that docsonnet is trying to work around: https://github.com/sh0rez/docsonnet?ts=4#whats-wrong-with-comments-why-not-parse-regular-comments Being able to create a link back to the source code in the generated documentation is the goal, while also making it easy on the user to write documentation |
I see. There is no way to implicitly depend on the caller's environment and this is very much by design. Eliminating this sort of magic from the configs is pretty much the point. Some limited, carefully designe mechanism for docs and debugging is not out of question, though. Fortunately, I think we can make it much better with existing features. We can simply pass the filename once per file, instead of passing it as an argument to every single function. For example:
or
This will require wrapping docsonnet stuff in a function which takes the filename, but then the user needs to pass it only once per file. Alternatively OOP-style can be used to the same effect:
What do you think? |
Loving this! Especially the last example makes it super easy to do this backwards compatible, no need to change existing imports. Also given we might introduce a desugared syntax for docsonnet soon, this would be hidden entirely from the user. |
Ya I was thinking about once per file for sure. Not a bad burden really, since you already need to copy/paste the import boilerplate anyway |
I'm satisfied that this issue should be closed |
Good, thanks! |
I'm working on a library that would greatly benefit from getting the filename of the caller of the function in which
std.theFile
is evaluated. Example:I know this would likely be hard because of the lazy evaluation of jsonnet, but maybe still possible?? no idea.
The text was updated successfully, but these errors were encountered: