3 ms·
Because `.foo` means `[‘foo’]` and because you can easily make sequences out of them (if you write `{ ... i1 = v1, v2, ... }` then `v2` automatically gets the “
by nikki93 8y ago
Because `.foo` means `[‘foo’]` and because you can easily make sequences out of them (if you write `{ ... i1 = v1, v2, ... }` then `v2` automatically gets the “next” natural number as a key) the ergonomics make them usable as structures and arrays easily. Also the ‘:foo()` syntax binds the LHS of the operator as the first parameter for a method call, and metamethods allow you to easily implement inheritance / dispatch / etc.
It’s more about ergonomics than availability.
- thanatropism 8y agoNot a full equivalence, but this[0] gets you x.foo, x.bar ergonomics as opposed to x['foo'] etc. [0] https://docs.python.org/3/library/types.html#types.SimpleNamespace https://docs.python.org/3/library/types.html#types.SimpleNam...
- majewsky 8y ago> `.foo` means `['foo']` Ruby does the same, except that it's `[:'foo']` because Ruby has two string types because fuck you.