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

Fix equality for Hy models #2083

Merged

Conversation

allison-casey
Copy link
Contributor

closes #1363

  • models are no longer equal to equivalent python literals
  • models only equal to models of the same kind
  • renamed wrap_value -> as_model and exposed under hy module

@allison-casey allison-casey force-pushed the feature/hy-model-equality branch from 0cd3920 to a4326f1 Compare June 4, 2021 16:03
@Kodiologist
Copy link
Member

This must have been a lot of work. Thanks a lot for doing this.

You should now be able to remove several checks of the form isinstance(…, Symbol) that are followed up immediately with an equality test; e.g., in the definiton of hy.model_patterns.sym.

It looks like the change wantedSymbol(wanted) in the commit labeled "Add: rename wrap_model -> as_model and expose under root hy module" belongs in a different commit.

Recurisvely promote an expr x

The input need not be an expression.

Don't forget the hyphen in "S-expression". That's an important hyphen, especially on gay-pride month. Actually, when talking about Hy, I usually just say "expression", if only because the model type is named Expression. Also, I would avoid the word "unquoted". Be a little more specific, like "values that aren't Hy models".

I think your use of "Python literal" to mean "unboxed value" (i.e., "ordinary value that's not a model") in a commit message and NEWS is confusing. Literals are elements of syntax, not objects.

The last commit mssage says "Docs:", but there are no documentation changes in that commit.

@Kodiologist Kodiologist changed the title hy model equality Fix equality for Hy models Jun 4, 2021
@Kodiologist
Copy link
Member

What's with all the additions of __hash__?

Why is Sequence.__eq__ necessary?

@allison-casey allison-casey force-pushed the feature/hy-model-equality branch 4 times, most recently from 5993e2e to 3cbd07c Compare June 5, 2021 02:39
@allison-casey
Copy link
Contributor Author

This must have been a lot of work. Thanks a lot for doing this.

not as long as pattern matching lol, but thats should be done soon just need to reorg the commits

You should now be able to remove several checks of the form isinstance(…, Symbol) that are followed up immediately with an equality test; e.g., in the definiton of hy.model_patterns.sym.

done

It looks like the change wanted → Symbol(wanted) in the commit labeled "Add: rename wrap_model -> as_model and expose under root hy module" belongs in a different commit.

Moved to correct commit

The input need not be an expression.

rephrased as "object"

Don't forget the hyphen in "S-expression". That's an important hyphen, especially on gay-pride month. Actually, when talking about Hy, I usually just say "expression", if only because the model type is named Expression. Also, I would avoid the word "unquoted". Be a little more specific, like "values that aren't Hy models".

Hy says gay rights 🏳️‍🌈
rephrased to be "expression", "non-hy model objects", and "associated Python values"

What's with all the additions of hash?

When you overwrite the __eq__ method of an immutable type it loses its hashability so you have to redefine it. made __hash__ an inherited method of Object to clean things up.

Why is Sequence.eq necessary?

Its not. removed

@allison-casey allison-casey force-pushed the feature/hy-model-equality branch from 3cbd07c to d75c056 Compare June 5, 2021 02:45
@Kodiologist Kodiologist force-pushed the feature/hy-model-equality branch from d75c056 to 0d6a53a Compare June 5, 2021 13:01
@Kodiologist
Copy link
Member

I've edited the PR to:

  • Remove a stray whitespace edit.
  • Capitalize "Hy" in prose.
  • Remove more Symbol type checks.

@allison-casey allison-casey merged commit 1d04a4a into hylang:master Jun 7, 2021
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.

Hy models have wrong equality
2 participants