-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Pony RT options passing #155
Open
alexsnaps
wants to merge
1
commit into
ponylang:main
Choose a base branch
from
alexsnaps:0065
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
- Feature Name: runtime-opts | ||
- Start Date: 2019-11-02 | ||
- RFC PR: | ||
- Pony Issue: | ||
|
||
# Summary | ||
|
||
This feature is a proposal to consolidate how we deal with these options, providing a way to avoid colissions with user defined options, upgrade and deprecation path across Pony releases. | ||
|
||
# Motivation | ||
|
||
The options (`--pony*`) provided to a compiled Pony program to control its runtime environment have evolved overtime, with the latest instance being the `--ponythreads` to `--ponymaxthreads` [rename](https://github.com/ponylang/ponyc/issues/3318). With the current approach, this change would silently ignore the old option. It could possibly fail further parsing within user's application, as recognized `--pony*` arguments are _not_ exposed through `Env.args` the old, yet the now "unused" option would be exposed. | ||
The opposite being just as true: a user specified option could be elided if the runtime would consume it in a subsequent release. Nothing prohibits a user from using the `--pony` prefix. | ||
|
||
# Detailed design | ||
|
||
Building upon [RFC-0064](0064-llvm-cli-opts-integration.md), as we probably should avoid introducing a new pattern, the proposal is to have a single option, namely `--pony_opts`, to pass all options as a single, comma seperated string, for the runtime to consume, e.g.: | ||
|
||
``` | ||
$ ./helloworld --pony_opts="minthreads=2,pin,maxthreads=4" | ||
Hello, world. | ||
``` | ||
|
||
Providing an unknown "key" within that string would result in an error: | ||
|
||
``` | ||
$ ./helloworld --pony_opts="minthreads=2,pin,maxthreads=4,answer=42" | ||
Unrecognized option answer, see --pony_opts=help for more information | ||
$ echo $? | ||
255 | ||
``` | ||
|
||
Also enabling for deprecation by providing a warning (on stderr?): | ||
|
||
``` | ||
$ ./helloworld --pony_opts="minthreads=2,pin,threads=4" | ||
Warning: the --pony_opts threads was renamed to maxthreads | ||
Hello, world. | ||
``` | ||
|
||
### Fill all the "other" details in! | ||
|
||
# How We Teach This | ||
|
||
By updating the documentation, as we've done so far with these changes. But once that change is in we'll fail early when unrecognized options are passed to the runtime, while providing a consistent experience for the executed program. | ||
|
||
# How We Test This | ||
|
||
I won't say "just as we do now", as... well, we currently don't! Formalizing this seems like the very time where we'd need to have proper test coverage to specify this behavior. That being said, proper unit test coverage should be all that's needed™. | ||
|
||
# Drawbacks | ||
|
||
The character for delimiting each runtime option is a problem this solution introduces. | ||
|
||
# Alternatives | ||
|
||
## Namespacing | ||
|
||
The `pony` prefix seems to be an agreed upon way to “qualify” arguments meant to be targeted to the runtime (GC, scheduler et al). Making `pony` an explicit namespace for the runtime to _consume_ all arguments in it. I'd make it explicit with a separator, (e.g. `:` , resulting in arguments in the fully qualified form of `--pony:maxthreads=3`, and making sure all passed arguments are recognized as valid arguments by the runtime. | ||
This provides a way forward for deprecation as well, as: | ||
* The new name is definitively available, as nothing is the pony: namespace ever gets exposed to the hosted program; | ||
* We can keep easily add aliasing, then warn and finally remove the “deprecated” name entirely over multiple releases. | ||
|
||
## One environment variable | ||
|
||
Having multiple come with the same downside as what we currently have. So we could pass the string to be parsed as an environment variable instead of an argument to the executable. | ||
|
||
# Unresolved questions | ||
|
||
The delimiter is, just as in [RFC-0064](0064-llvm-cli-opts-integration.md), an obvious issue: what character, or sequence there of, is most likely not to be used in an actual value for all future options to come? And if we get it wrong how do we best escape it? | ||
|
||
What do we do about `--ponyhelp` and `--ponyversion`? While these are useful and should probably stick around, they aren't like any other option, as they shortcircuit the actual program's execution. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
--pony-opts
might be more idiomatic for CLI than--pony_opts
?That is, dashes are probably more idiomatic than underscores.