Make --preserve-order a global CLI flag instead of per-function parameter#218
Draft
vivainio wants to merge 1 commit intoCertainLach:masterfrom
Draft
Make --preserve-order a global CLI flag instead of per-function parameter#218vivainio wants to merge 1 commit intoCertainLach:masterfrom
vivainio wants to merge 1 commit intoCertainLach:masterfrom
Conversation
… parameter Replace the exp-preserve-order feature flag and per-function preserve_order parameters with a global thread-local setting, following the existing STACK_LIMIT pattern. The --preserve-order CLI flag sets this globally, affecting all object field iteration without polluting stdlib function signatures. This removes ~400 lines of cfg-gated code and parameter threading while keeping the same functionality.
This was referenced Apr 12, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
exp-preserve-orderfeature flag and per-functionpreserve_orderparameters with a global thread-local setting (following the existingSTACK_LIMITpattern)--preserve-orderCLI flag sets this globally, affecting all object field iteration without polluting stdlib function signatures#[cfg]-gated code and parameter threadingMotivation
Feedback on #217: adding
preserve_orderto every stdlib function pollutes the API surface. A global flag is cleaner — users who want preserved order want it everywhere, not per-call.How it works
PRESERVE_ORDER: Cell<bool>inobj/mod.rswithset_preserve_order()/preserve_order()accessorsObjValue::fields(),iter(), etc. read the global setting instead of taking a parameterset_preserve_order(true)at startup when--preserve-orderis passedorderingmodule (withFieldIndex/SuperDepthtracking) is always compiled — no more no-op stubTest plan
cargo buildsucceedscargo testpassesjrsonnet -e '{ c: 1, b: 2, a: 3 }'outputs alphabetical orderjrsonnet --preserve-order -e '{ c: 1, b: 2, a: 3 }'preserves declaration order