Skip to content
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

Add a field order option for the pretty-printer #1199

Merged
merged 3 commits into from
May 25, 2021

Conversation

dmwit
Copy link
Contributor

@dmwit dmwit commented May 25, 2021

We're working on a cryptol-to-C compiler, and one way we've been validating that it's working right is to use the cryptol repl's :dumptests feature and a small C wrapper that treats them as golden tests. I'd like to keep the C wrapper's parser simple, and if records get printed with a predictable field order, that simplifies the parser a lot.

This pull request adds a feature for this: a new setting, fieldOrder/field-order in the REPL, which can be set to canonical or display, and which controls the pretty-printer for records. It defaults to display for backwards compatibility.

(Actually, I'm going to use a different branch than master for the C compiler, but I'd like to minimize drift between them if possible.)

dmwit added 3 commits May 25, 2021 00:09
For human consumers, it's usually nice to show record fields in the same
order they appear in the source (as sometimes programmers use the field
order as a communication channel to other programmers). However, for
machine consumers, sometimes it is nicer to adhere to a rigid,
predictable format. This commit adds a setting, `field-order`, to switch
between these two modes, with a backward-compatible default.
@dmwit dmwit requested review from yav and robdockins May 25, 2021 04:22
Copy link
Member

@yav yav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me

@dmwit dmwit merged commit bd8588a into master May 25, 2021
@dmwit dmwit deleted the feature/master-field-order branch May 25, 2021 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants