user-documentation
user-documentation copied to clipboard
Clarify subtyping for shapes
Numerous typos found:
Types: Shapes
Consider a shape type S2 whose field set is a superset of that in shape type S1. As such, S2 is a subtype of S1.If S2 is a superset of S1, how can it be a subtype of S1?
Expressions And Operators: Await, Source Code Fundamentals: Namespaces, Attributes: Predefined Attributes, Types: Classes
$$in the links
Asynchronous Operations: Guidelines
memmoizedhas too many m's- memoize example should have <<__Memoize>>
I found more but they seem to have been corrected in the past few weeks and many of those pages have disappeared so props to getting all those fixed.
Please don't change anything below this point.
- Build ID: 2019-03-15T20:34:09+0000:361688e6c740dea5615800d530efcf4090ad0b4c
- Page requested: /hack/types/shapes
- Page requested at: Wed, 27 Mar 2019 21:26:25 +0000
- Controller: GuidePageController
Thanks for the report!
If S2 is a superset of S1, how can it be a subtype of S1?
You can pass a shape('x' => int, 'y' => int) to a function that's only expecting a shape('x' => int). You can think of the shape with more fields as more specific, which is what subtyping gives.
Similarly I could have a class Animal with a subtype Dog. That subclass Dog might have additional properties (like $this->tail). So Dog's properties are a superset of Animal.
We could certainly look at clarifying this section though.
$$ in the links
Duplicate of #594.