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

Fix misleading example of open object types #768

Open
wants to merge 1 commit into
base: source
Choose a base branch
from

Conversation

YawarRaza7349
Copy link

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?

Open object types exist to enable polymorphism, but the old example did not use open object types polymorphically.
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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants