Fix misleading example of open object types#768
Open
YawarRaza7349 wants to merge 1 commit intoreasonml:sourcefrom
Open
Fix misleading example of open object types#768YawarRaza7349 wants to merge 1 commit intoreasonml:sourcefrom
YawarRaza7349 wants to merge 1 commit intoreasonml:sourcefrom
Conversation
Open object types exist to enable polymorphism, but the old example did not use open object types polymorphically.
davesnx
reviewed
Dec 1, 2023
Comment on lines
+29
to
30
| Two dots, also called an elision, indicate that this is an "open" object type, and therefore can also contain other values and methods. An open object is also polymorphic and therefore requires a parameter. This parameter refers to the complete type of the object, including those other values and methods. | ||
|
|
Member
There was a problem hiding this comment.
Agree here with you that this isn't right, since open object is the form of structural typing.
I'm not sure if this entire paragraph make sense after your addition thought. Since you refer to the as 'a without being very explicit.
Author
There was a problem hiding this comment.
Just checking: By "Agree with you that this isn't right", are you referring to the old code example, rather than the part that is quoted here?
I don't see how the sentence I added would cause the paragraph to make less sense than it did previously. It already referred to the 'a when it said "and therefore requires a parameter".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The given example using an open object type isn't how one would actually use it. The point of an open object type is so one can write code that works across multiple concrete object types that share some, but not all, of their fields. I made it so that the example is closer to how one would actually use the language feature to achieve this purpose.
Also, I think there's a lot of room for improvement for the Object page as a whole. What do other people think?