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

Discuss name of DataPayload get method #740

Closed
sffc opened this issue May 28, 2021 · 4 comments
Closed

Discuss name of DataPayload get method #740

sffc opened this issue May 28, 2021 · 4 comments
Assignees
Labels
C-data-infra Component: provider, datagen, fallback, adapters R-as-designed Resolution: By design principles, this won't be fixed S-small Size: One afternoon (small bug fix or enhancement) T-techdebt Type: ICU4X code health and tech debt

Comments

@sffc
Copy link
Member

sffc commented May 28, 2021

@zbraniecki said in #739:

I strongly believe borrow is a better name here than get.

I replied:

There are some things I like about borrow, and I considered it, but I used get because:

  • It's shorter
  • It's what Yoke uses
  • .borrow() is the name of the function in the std::borrow::Borrow trait, which we are not implementing

Discuss.

@sffc sffc added the discuss Discuss at a future ICU4X-SC meeting label May 28, 2021
@sffc
Copy link
Member Author

sffc commented May 28, 2021

Bikeshed:

  • .as_data()
  • .as_inner()
  • .get_inner()
  • .borrow_inner()

@sffc
Copy link
Member Author

sffc commented Jun 4, 2021

  • @zbraniecki - I think it's okay to have a function with the same name as the standard library trait if it is similar; for example, .iter() does not necessarily return an Iterator.
  • @nordzilla - I'm okay re-using the same method name
  • @echeran - What's wrong with .get() ?
  • @zbraniecki - Usually .get() is fallible, and gets something out of a collection, but here you are borrowing an inner type. So it's more like RefCell, which has a .borrow() function.
  • @Manishearth - Perhaps .as() or .as_borrow() or .inner()?
  • @dminor - I like .inner()
  • @nordzilla - I like .inner() or .borrow_inner()

Resolution: use .inner(), for now only on DataPayload. @Manishearth can decide whether to also change Yoke.

@sffc sffc added C-data-infra Component: provider, datagen, fallback, adapters S-small Size: One afternoon (small bug fix or enhancement) T-techdebt Type: ICU4X code health and tech debt and removed discuss Discuss at a future ICU4X-SC meeting labels Jun 4, 2021
@sffc sffc added this to the 2021 Q3-m1 milestone Jun 4, 2021
@sffc sffc self-assigned this Jun 4, 2021
@sffc sffc added the discuss Discuss at a future ICU4X-SC meeting label Jul 23, 2021
@sffc
Copy link
Member Author

sffc commented Jul 23, 2021

I want to revisit the decision above, because .inner() is a bit of a misnomer: we're returning the yoked object, not the yoke itself. I would expect .inner() to return a Yoke<T, C>, but instead we return T directly.

I prefer to keep .get() and close this issue.

@sffc sffc removed this from the 2021 Q3-m1 milestone Jul 23, 2021
@sffc
Copy link
Member Author

sffc commented Jul 29, 2021

2021-07-29: Okay. Keep .get(). Zibi is 2/10.

@sffc sffc closed this as completed Jul 29, 2021
@sffc sffc added R-as-designed Resolution: By design principles, this won't be fixed and removed discuss Discuss at a future ICU4X-SC meeting labels Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-data-infra Component: provider, datagen, fallback, adapters R-as-designed Resolution: By design principles, this won't be fixed S-small Size: One afternoon (small bug fix or enhancement) T-techdebt Type: ICU4X code health and tech debt
Projects
None yet
Development

No branches or pull requests

1 participant