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

[range.dangling] The tag of a struct is not a C++ term #5922

Merged
merged 1 commit into from Nov 1, 2022

Conversation

hawkinsw
Copy link
Contributor

Only in C is the term tag defined with respect to structs. Replace the term "tag type" with simply "type" in [range.dangling].

Only in C is the term `tag` defined with respect to `struct`s. Replace
the term "tag type" with simply "type" in [range.dangling].
@jwakely
Copy link
Member

jwakely commented Oct 29, 2022

This isn't talking about "the tag of a struct" though. It's a tag type as in "tag dispatching" https://www.fluentcpp.com/2018/04/27/tag-dispatching/

@jwakely
Copy link
Member

jwakely commented Oct 29, 2022

@hawkinsw
Copy link
Contributor Author

hawkinsw commented Oct 29, 2022 via email

@hawkinsw
Copy link
Contributor Author

Upon further reflection, I still believe this is a good change to make. I am also concerned by the sentence

In such cases, the type dangling is returned instead of an iterator or subrange.

which seems to conflate returning a type with returning an object of a certain type.

It seems to me that this would be better phrased as

In such cases, an object of type dangling is returned instead of an object whose type is an iterator or subrange.

@JohelEGP
Copy link
Contributor

There's no object involved in return dangling{};. See https://eel.is/c++draft/stmt.return#2.sentence-4 and https://wg21.link/LWG3805.

@hawkinsw
Copy link
Contributor Author

hawkinsw commented Oct 29, 2022 via email

@hawkinsw
Copy link
Contributor Author

There's no object involved in return dangling{};. See https://eel.is/c++draft/stmt.return#2.sentence-4 and https://wg21.link/LWG3805.

It will be interesting to see the resolution to the issue that you have open!

@JohelEGP
Copy link
Contributor

I'm not sure. There's also the example of https://eel.is/c++draft/std.iterator.tags#1.sentence-2.

@hawkinsw
Copy link
Contributor Author

hawkinsw commented Oct 29, 2022 via email

@hawkinsw
Copy link
Contributor Author

hawkinsw commented Oct 29, 2022 via email

@JohelEGP
Copy link
Contributor

It already does. It says "tag type".

@hawkinsw
Copy link
Contributor Author

hawkinsw commented Oct 29, 2022 via email

@JohelEGP
Copy link
Contributor

I am just trying to be helpful.

We all are. Obviously, the "something more" you meant wasn't the preexisting "tag". I shouldn't have taken it literally.

Now I'm questioning the use of "tag" standing for "tag dispatching". Unlike the iterator's tag dispatching, this one is on the way out. And the tag is actually "whether the range argument is an rvalue", whereas dangling is the result of the dispatch.

The

something more than just "type"

you suggest exists in the whole paragraph, which attempts to explain what "tag" alone couldn't. So I think just dropping "tag" is an improvement in face of the potential confusion with the C term and "tag" as an adjective being an undefined term for types.

@hawkinsw
Copy link
Contributor Author

I am just trying to be helpful.

We all are. Obviously, the "something more" you meant wasn't the preexisting "tag". I shouldn't have taken it literally.

No problem! I get nervous in these situations because everyone else is the expert!

Now I'm questioning the use of "tag" standing for "tag dispatching". Unlike the iterator's tag dispatching, this one is on the way out. And the tag is actually "whether the range argument is an rvalue", whereas dangling is the result of the dispatch.

The

something more than just "type"

you suggest exists in the whole paragraph, which attempts to explain what "tag" alone couldn't. So I think just dropping "tag" is an improvement in face of the potential confusion with the C term and "tag" as an adjective being an undefined term for types.

If I hear you correctly, then you think that the original PR (where we simply drop the tag word) is good?

Thanks again for engaging!

@JohelEGP
Copy link
Contributor

If I hear you correctly, then you think that the original PR (where we simply drop the tag word) is good?

I personally do. We'll have to see what the experts think.

@hawkinsw
Copy link
Contributor Author

If I hear you correctly, then you think that the original PR (where we simply drop the tag word) is good?

I personally do. We'll have to see what the experts think.

Fair enough, but I think you're an expert! :-)

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

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

This looks like an improvement to me, because it avoids the confusion with C struct tags. And it's not an iterator category tag, either (for tag dispatching).

@jwakely , what do you think?

@hawkinsw
Copy link
Contributor Author

hawkinsw commented Oct 30, 2022 via email

Copy link
Contributor

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

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

"tag" really isn't contributing anything here.

@hawkinsw
Copy link
Contributor Author

"tag" really isn't contributing anything here.

Thank you @CaseyCarter !

@jwakely
Copy link
Member

jwakely commented Oct 31, 2022

And it's not an iterator category tag, either (for tag dispatching).

Iterator tags aren't the only kind of tags used for tag dispatching though. I'd prefer to keep it, but then we'd have to define tag dispatching (or tag types) in the standard. So I will let it go, somewhat reluctantly.

@hawkinsw
Copy link
Contributor Author

And it's not an iterator category tag, either (for tag dispatching).

Iterator tags aren't the only kind of tags used for tag dispatching though. I'd prefer to keep it, but then we'd have to define tag dispatching (or tag types) in the standard. So I will let it go, somewhat reluctantly.

I'd be willing to work with you on defining that phrase and introducing it, if you'd like!! @jwakely

@jensmaurer
Copy link
Member

(While I understand the type dangling may be used for tag dispatching, I thought its primary purpose for users is to make careless programs ill-formed.)

@jensmaurer
Copy link
Member

@tkoeppe , on to you.

@tkoeppe tkoeppe merged commit 90aa772 into cplusplus:main Nov 1, 2022
@jwakely
Copy link
Member

jwakely commented Nov 1, 2022

its primary purpose for users is to make careless programs ill-formed.

Calling another algorithm with the result either dispatches to a function taking an iterator, or fails to compile (i.e. dispatches to nothing). Using the return type to select a valid overload or an invalid overload is a form of tag dispatching IMO.

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.

None yet

6 participants