-
Notifications
You must be signed in to change notification settings - Fork 96
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
Rename and re-organize primitive operators #1937
Merged
Merged
Conversation
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
This was referenced Jun 3, 2024
Although this PR is also blocked on the |
jneem
approved these changes
Jun 6, 2024
yannham
force-pushed
the
refactor/primop-better-names
branch
from
June 7, 2024 09:16
7f139b9
to
fd78dfd
Compare
yannham
force-pushed
the
refactor/primop-better-names
branch
from
June 7, 2024 09:20
fd78dfd
to
8fead1c
Compare
yannham
force-pushed
the
refactor/primop-better-names
branch
from
June 7, 2024 09:31
8fead1c
to
c1be53e
Compare
Primitive operators haven't got much love, as opposed to user-facing interfaces like the stdlib, and they have grown organically since the beginning of the very first Nickel prototype. As a result, the naming is inconsistent, with several generations, both in the surface syntax of Nickel and internally in the Rust codebase. This PR makes a cleaning pass on primitive operators, by: 1. Use full worlds in the style of the current stdlib: `str` -> `string`, `num` -> `number`, etc. 2. Introduce pseudo-namespaces: instead of `str_foo` and `record_bar`, we use `/` as a separator for categories. The previous examples become `string/foo` and `record/bar`. We don't use `.`, to make it clear that it's not a normal record access, but just a nice way to dinstinguish the different categories 3. Align old operators on the current naming in the standard library.
yannham
force-pushed
the
refactor/primop-better-names
branch
from
June 7, 2024 11:07
c1be53e
to
0d45fb6
Compare
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jul 10, 2024
* clean up outdated primitive operator names PR #1937 recently renamed many primitive operators. It missed some instances of the previous names, though. In particular: - error messages - comments - an unused function "apply_contract" in core/src/term/mod.rs While most of these names were only made obsolete in #1937, some of them have been incorrect for longer, eg "%array_access%" in core/src/term/pattern/compile.rs and "recordMap" in core/src/term/mod.rs. I caught as many as I could find. However it's hard to be sure I got all of them, given that some of the previous names are very general terms like "value", "fields", "length", and "map". The full list of renames I identifiend are as follows, formatted as "<old name> <new name>". First, the easy cases: chng_pol label/flip_polarity record_map record/map str_trim string/trim str_chars string/chars str_uppercase string/uppercase str_lowercase string/lowercase str_length string/length str_from to_string num_from number/from_string enum_from enum/from_string str_is_match string/is_match str_find string/find str_find_all string/find_all record_empty_with_tail record/empty_with_tail label_push_diag label/push_diag enum_unwrap_variant enum/unwrap_variant enum_is_variant enum/is_variant enum_get_tag enum/get_tag apply_contract contract/apply array_lazy_app_ctr contract/array_lazy_app record_lazy_app_ctr contract/record_lazy_app elem_at array/at str_split string/split str_contains string/contains record_insert record/insert record_insert_with_opts record/insert_with_opts record_remove record/remove record_remove_with_opts record/remove_with_opts label_with_message label/with_message label_with_notes label/with_notes label_append_note label/append_note str_replace string/replace str_replace_regex string/replace_regex str_substr string/substr record_seal_tail record/seal_tail record_unseal_tail record/unseal_tail array_slice array/slice Then the harder cases: polarity label/polarity go_dom label/go_dom go_codom label/go_codom go_array label/go_array go_dict label/go_dict embed enum/embed map array/map generate array/generate length array/length fields record/fields fields_with_opts record/fields_with_opts values record/values go_field label/go_field has_field record/has_field has_field_with_opts record/has_field_with_opts field_is_defined record/field_is_defined field_is_defined_with_opts record/field_is_defined_with_opts lookup_type_variable label/lookup_type_variable insert_type_variable label/insert_type_variable Finally, two cases that I didn't understand and seem to be unused: rec_force_op op rec_force rec_default_op op rec_default * address code review comments
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.
Primitive operators haven't got much love, as opposed to user-facing interfaces like the stdlib, and they have grown organically since the beginning of the very first Nickel prototype. As a result, the naming is inconsistent, with several generations, both in the surface syntax of Nickel and internally in the Rust codebase.
This PR makes a cleaning pass on primitive operators, by:
str
->string
,num
->number
, etc.str_foo
andrecord_bar
, we use/
as a separator for categories. The previous examples becomestring/foo
andrecord/bar
. We don't use.
, to make it clear that it's not a normal record access, but just a nice way to dinstinguish the different categoriesThis PR is mostly read for review, but in order to appease the CI, I need to update the tree-sitter grammar first to accommodate for the
/
character in primops.