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

equals and List's indexOf have very poor names #960

Closed
DartBot opened this issue Dec 25, 2011 · 2 comments
Closed

equals and List's indexOf have very poor names #960

DartBot opened this issue Dec 25, 2011 · 2 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Dec 25, 2011

This issue was originally filed by @darrellpf


The use of List's 'indexOf' and Object's 'equals' are very poor names. This leads to a great deal of confusion about their usage.

'indexOf' is really "find a match for". The important idea is not that it gives back a position, but that it is attempting to match based on some criteria supplied by the equals method.

'equals' is really "is similar to", or "looks enough like". I hesitate to use the word 'matches' because that causes confusion with regular expression terminology. Having an conversation that tries to talk about = (the symbol) versus equals (the matching function) versus == (or now ===) is very difficult.

The unfortunate names are a holdover from their Java counterparts. The names cause a lot of confusion with beginning programmers. It would be helpful if they were changed to be more meaningful.

@dgrove
Copy link
Contributor

dgrove commented Jan 2, 2012

Removed Type-Defect label.
Added Type-Enhancement, Area-Library, Triaged labels.

@lrhn
Copy link
Member

lrhn commented Oct 24, 2012

Equals is no longer called that, but the effect is the same: The operator== on objects should define an equivalence relation. I.e., 'equals' really mans 'equals', not 'similar to', but it also doesn't mean 'identical'. If you look at the world through the glasses of that equivalence relation, indexOf is really looking for the position of that value in the list - but not necessarily that exact object.


Added WontFix label.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Oct 24, 2012
@kevmoo kevmoo added closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug and removed resolution-wont_fix labels Mar 1, 2016
dart-bot pushed a commit that referenced this issue Nov 19, 2020
2020-11-19 [email protected] #926.Add Platform.executableArguments to Process.run() command to not to fail on --enable-assert configuration
2020-11-19 [email protected] #926.Add Platform.executableArguments to Process.run() command to not to fail on --enable-assert configuration
2020-11-18 [email protected] Fixes #966. Move certificates to RawSecureServerSocket directory
2020-11-18 [email protected] #926. Fixed test that fail on precompiled environment in a strong mode
2020-11-17 [email protected] Fixes #951. Remove excessive @static-warning
2020-11-17 [email protected] Fixes #946: LanguageFeatures/Instantiate-to-bound/nonfunction_typedef tests updated according to the SDK changes, missing tests added.
2020-11-17 [email protected] #932. Some HttpRequest tests fixed to work well with cross origin requests
2020-11-16 [email protected] Process kill test fixed to work on different platforms
2020-11-16 [email protected] External variable test that expects compile time error on dart2js added
2020-11-13 [email protected] Fixes #926. Remove "--enable-experiment=non-nullable" option from script that runs another process
2020-11-12 [email protected] #926. File lock checking tests rewritten to not to fail on precompiled environment. Second part
2020-11-12 [email protected] Fixes #602: Missing issue tags added.
2020-11-11 [email protected] #926. File lock checking tests rewritten to not to fail on precompiled environment
2020-11-11 [email protected] Issue numbers added
2020-11-11 [email protected] Fixes #963: test expected result corrected, test template for all generic typedefs updated.
2020-11-10 [email protected] #926. ProcessSignal tests rewritten to not to fail on precompiled environment
2020-11-10 [email protected] #926. Process tests rewritten to not to fail on precompiled environment
2020-11-10 [email protected] #961. Process tests rewritten to not to use process_test tool
2020-11-10 [email protected] Fixes #602: Missing Issue tag added.
2020-11-10 [email protected] Fixes #960. Null safety execution modes renamed and mentions of obsolete checked mode removed
2020-11-10 [email protected] Remove wrong error expectations
2020-11-09 [email protected] Fixes #962. Change CFE error messages expectations
2020-11-08 [email protected] Fixes #602: New tests for least and greatest closures added.

Cq-Include-Trybots: dart/try:analyzer-nnbd-linux-release-try,dart2js-nnbd-linux-x64-chrome-try,ddc-nnbd-linux-release-chrome-try,front-end-nnbd-win-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-nnbd-win-release-x64-try
Change-Id: I7aff067ec96f762490de15daa20c40dff2b0ae96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172940
Reviewed-by: William Hesse <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants