user-documentation icon indicating copy to clipboard operation
user-documentation copied to clipboard

Clarify that "Arrays" documentation includes vec, dict, and keyset

Open ryangreenberg opened this issue 4 years ago • 8 comments

I fielded an internal question at Slack about how to append objects to vecs, and more generally where to find this information in the docs. I pointed to https://docs.hhvm.com/hack/built-in-types/arrays, which explains how to do $colors = vec[]; $colors[] = 'red';.

It's a little confusing to expect people to click into the "Arrays" section to find information about how to use vec/dict/keyset, especially if they have heard that PHP arrays are being replaced with something else.

Maybe move the vec/dict/keyset information to a separate page, or include them in the name of this one?

ryangreenberg avatar Dec 02 '19 16:12 ryangreenberg

Seems reasonable, that page is way too long anyway so probably worth splitting.

jjergus avatar Dec 02 '19 19:12 jjergus

The name 'hack arrays' itself seems like a PHPism when it includes 'dict' - unfortunately 'collections' is already taken :(

fredemmott avatar Dec 19 '19 00:12 fredemmott

perhaps we should rename the page to "Containers"?

fredemmott avatar Dec 19 '19 00:12 fredemmott

That also seems unwise as there's a Container type. I fear we've exhausted all the obvious names.

Wilfred avatar Dec 19 '19 10:12 Wilfred

At least the “Container” type is a super type of the others :p

fredemmott avatar Dec 19 '19 16:12 fredemmott

"Containers" seems fine to me but also we could just call it "vec, dict, keyset" or even "Containers (vec, dict, keyset)" if there's enough space.

jjergus avatar Dec 19 '19 18:12 jjergus

"Containers" page could also briefly mention the interfaces (Container, Traversable, Keyed...); I think we previously covered that as part of the documentation about collections.

jjergus avatar Dec 19 '19 18:12 jjergus

Seems reasonable, that page is way too long anyway so probably worth splitting.

This is increasingly seeming like the right approach to me - perhaps:

  • separate pages for each of vec, dict, and keyset
  • separate page for the cheat sheet
  • another, shared page for all 'legacy containers'

fredemmott avatar Dec 19 '19 19:12 fredemmott

The page has received an update since this issue was filed. It now starts with:


Hack includes diverse range of array-like data structures.

Hack arrays are value types for storing iterable data. The types available are vec, dict and keyset. When in doubt, use Hack arrays.

Closing this issue, but feel free to file another if I've missed something from the conversation.

lexidor avatar May 25 '23 21:05 lexidor