-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Adding Equality Operators to Templates #560
Adding Equality Operators to Templates #560
Conversation
I'll admit it's not very constructive feedback, but can we call it |
@balinterdi It's one of the points in the Unresolved questions section. Let's someone from core chime in and arguments the reasons to prefer |
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.
yes, please! 🙏
- If an app already use `ember-truth-helpers`, the `{{eq}}` helper will conflict with the one proposed here. How do we | ||
update `ember-truth-helpers` to make sure the helper of the same name doesn't collide with the built-in one? | ||
- The inequality helper proposed in this RFC is `{{neq}}` while the one in ember-truth-helpers is `{{not-eq}}`. It is | ||
worth considering the benefits that keeping the same name might have in helping apps and addon migrate to the built-in helper. |
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.
this could easily be migrated using a template codemod, so probably not much of an issue in reality :)
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.
Sure, but nothing beats not having to change anything 😄
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.
@Turbo87 And you have to admit: neq
looks way worse than not-eq
.
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.
I mean, one could argue that (not (eq foo bar))
is not much longer than (not-eq foo bar)
😅
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.
Fair enough, I'm happy with (not (eq ... ))
, too. I don't think gaining 3 characters (neq
vs. not-eq
) justifies introducing a so-far unseen neq
but I might just have a visceral reaction to neq
that I have to overcome.
Why not add all truth-helpers, but just these two? |
@Driezzz because these are the most uncontroversial |
Add `{{eq}}` and `{{neq}}` helpers. | ||
|
||
#### `{{eq}}` | ||
Binary operation. Throws an error if not called with exactly two arguments. |
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.
I think we should allow many arguments with eq
, behaving like:
a === b === c
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.
@rwjblue is that consensuated with the core team? I'm fine either way, I just want to be sure before updating it.
Accidentally commented 😩 here instead of #562We chatted about this in todays core team meeting, and are in favor of moving forward here.One thing to call out explicitly, this RFC does not propose import paths (which helpers would require see the strict mode RFC for details). At the time of authoring, that distinction was not present (which is why it isn't discussed here), but after discussion with the core team we think that making these keywords (which do not need imports) is the correct path anyways (therefore no changes are required to the RFC). Additionally, landing this in Ember will require a small deprecation when using All of that being said, we are moving this into final comment period (finally 😉). |
Dangit! I meant to make that comment over on #562 not this one. 🤦 |
Note: we did talk about this RFC quite a bit also, and I do think that we want to move forward soon. There are just a few other angles that we wanted to talk through (e.g. should there be a way to customize equality or not vs "simple" |
IMHO it's complicated enough to explain that empty arrays in HBS are falsy. if equality was also redefined to work different from |
We discussed this a bit more this week, and are still very much in favor of moving forward.
Agreed. I think this is well stated, and when we discussed it more at todays meeting we shared your conclusion. Remaining questions that we want to resolve (either in a GlimmerVM team meeting or the next core team meeting):
Hopefully, we'll be able to resolve those two issues at the next round of meetings. |
I think this might be overthinking it. First, IDK if helpers are guaranteed to have stable outputs, at least with class-based-helpers I believe you could perfectly not be the case. Trying to be that smart just to remove a == operation (or |
Hehe, I don't disagree with you (see my personal note in that snippet); buuuuuutttt sometimes it's what we do. 😺 |
Thanks @pzuraq for adding that section around object equality scenarios (and some potential gotchas there). We discussed this today, and we are moving this into FCP. |
it require less mental parsing, especially for non native speakers and new developers. Same as related: glimmerjs/glimmer-vm#1240 (comment) |
We discussed this at todays meeting, and are still in favor of moving forward. |
We discussed the dasherization (or not) a while back, and had previously decided to go with In retrospect, we decided not to make these helpers require being imported (see #562 (comment) for some discussion RE: keywords vs helpers) and so |
@chriskrycho I was under the impression these would be part of the "prelude". |
I have gotten conflicting impressions at different times! I think it is fine for these (along with things like |
Extracted from RFC #388
Rendered