Skip to content

Add documentation for language-supplied == and != on unions#28957

Open
bradcray wants to merge 1 commit into
chapel-lang:mainfrom
bradcray:doc-union-comparison-ops
Open

Add documentation for language-supplied == and != on unions#28957
bradcray wants to merge 1 commit into
chapel-lang:mainfrom
bradcray:doc-union-comparison-ops

Conversation

@bradcray

Copy link
Copy Markdown
Member

This adds a description to the language spec of the Chapel-supplied == and != operators on unions, as added in #14139 (apparently it didn't occur to me or my reviewer to add them then).

While here, I reordered and changed the level of a few sections in this chapter to match the records chapter, which I believe has received more attention in recent years. Specifically, I moved the bit about declaring union types ahead of the section about referring to union types (since one must exist before you can name it, and naming it is strictly less interesting), and I moved assignment and these newly added comparisons into a "Common Operations" section to match records.

While here, I reordered and changed the headings of a few sections
in this chapter to match the records chapter, which I believe has
received more attention in recent years.

---
Signed-off-by: Brad Chamberlain <bradcray@users.noreply.github.com>
Comment thread doc/rst/language/spec/unions.rst
types, a compiler error is generated.

These default comparisons consider two union values to be equal if (a)
both union have the same active field and (b) those fields are

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bit of a nit, since it's clear what you mean, but "those fieldS" is mismatched with "same active field". Consider: "the respective values of this active field are..."

union-type:
identifier

The union type is specified by the name of the union type. This

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would help me to know that union-type is part of the type expression grammar. Because "union type is specified" is rough, and to me seems a little too close to "defined". I think perhaps we can adjust the opening paragraph of this section to say "The syntax of a union type expression is summarized as follows"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is pre-existing (it just got moved), but I agree with the notion of improving it while I'm here.

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