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

What's a "first-class object"? #5034

Closed
burblebee opened this issue Oct 17, 2021 · 7 comments · Fixed by #5067
Closed

What's a "first-class object"? #5034

burblebee opened this issue Oct 17, 2021 · 7 comments · Fixed by #5067
Assignees

Comments

@burblebee
Copy link
Contributor

problem with paper/spec:
What is a "first-class object"? There are 2 uses of this undefined term.

Originally posted by @burblebee in #5013 (comment)

@hubert-reinterpretcast
Copy link
Contributor

I think it's questionable what the sentences that use this term are really trying to say. As in, does the use of "functions" in those sentences actually mean "functions" in the core language sense? Perhaps. In which case, the sentence means that, with the wrapper functionality, core language functions act as, and can be made into, callable objects.

@jensmaurer
Copy link
Member

Agreed this needs fixing.

@jwakely
Copy link
Member

jwakely commented Oct 23, 2021

I think it's questionable what the sentences that use this term are really trying to say. As in, does the use of "functions" in those sentences actually mean "functions" in the core language sense?

Yes.

Perhaps. In which case, the sentence means that, with the wrapper functionality, core language functions act as, and can be made into, callable objects.

Right, which is true. ("Callable object" is defined by the library). But you can also turn a function into a callable object just by taking its address, as a function pointer is a callable object.

"First-class object" is a commonly used term in the field of programming languages, but we can remove it if it's a problem. The end of that sentence isn't adding anything. The point of move_only_function is type erasure, to hide the differences between different types of callable object with a given call signature. Creating first-class objects is not the main advantage.

@tkoeppe
Copy link
Contributor

tkoeppe commented Oct 23, 2021

"First-class object" is a commonly used term in the field of programming languages, but we can remove it if it's a problem. The end of that sentence isn't adding anything. The point of move_only_function is type erasure, to hide the differences between different types of callable object with a given call signature. Creating first-class objects is not the main advantage.

I'm not a fan of this alleged term at all. It ranks right up there with "safe" as a term that's unhelpful and nebulous and could easiy be replaced by a more appropriate term. How is a a first-class object different from any other kind of object? What other classes are there? Why not just "object"?

I would not shed a tear over losing this sentence entirely.

@jensmaurer
Copy link
Member

Obviously, a first-class object is an object that has bells, whistles, and skids, so let's get rid of that phrase.

@jwakely
Copy link
Member

jwakely commented Oct 23, 2021

It's a term that has its own Wikipedia page.

https://en.m.wikipedia.org/wiki/First-class_citizen

@jwakely
Copy link
Member

jwakely commented Oct 23, 2021

And given the existing but sightly different meaning of "object" in C++, maybe saying first-class citizen would have been better here. But removing it doesn't decrease the usefulness or correctness of those paragraphs so I agree with removing it.

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 a pull request may close this issue.

5 participants