4 ms·
So it appears this follows the terrible C++ "naming things with the wrong name on purpose" trend, with the biggest example being naming a variable length array
by lloydatkinson 2y ago
So it appears this follows the terrible C++ "naming things with the wrong name on purpose" trend, with the biggest example being naming a variable length array (a list, collection, etc) `std:vector` even though Vector was already a well known word with a very different meaning.
The word/type they wanted for this was the Unit type: https://en.wikipedia.org/wiki/Unit_type https://en.wikipedia.org/wiki/Unit_type and in that list it even states the `std:monotype` is a Unit.
- codeflo 2y agoFunctor is one of the worst offenders IMO. In C++ lingo, it simply means "callable object".
- halayli 2y agoIn C++ lingo they are called function objects or callables, not functor. You might stumble on code here and there that suffix a class name with Functor but it's not that common.
- codeflo 2y agoMany blog posts and Stackoverflow questions about C++ cal them functors. Boost of all things uses the term in its definitions: https://www.boost.org/doc/libs/1_60_0/doc/html/function/reference.html#header.boost.function_hpp https://www.boost.org/doc/libs/1_60_0/doc/html/function/refe... It's common enough that articles have been written against this usage: https://web.archive.org/web/20170224220253/http://jackieokay.com/2017/01/26/functors.html https://web.archive.org/web/20170224220253/http://jackieokay... So this usage of functor may never have been "official", but it's widespread in the community.
- plorkyeran 2y agoI would say it was widespread, but it's now fallen out of favor. Alexandrescu got the name wrong 25 years ago† and that got embedded into early boost, but by the time that blog post was written I feel like I'd mostly stopped seeing it being used by C++ experts. † I don't know if the original mistake was his, but he certainly did a lot to spread it.
- Maxatar 2y agocppreference.com uses the term functor in numerous places for recent C++ features including things in C++26 such as reflection: https://en.cppreference.com/w/cpp/experimental/reflect https://en.cppreference.com/w/cpp/experimental/reflect https://en.cppreference.com/w/cpp/utility/variant/visit2 https://en.cppreference.com/w/cpp/utility/variant/visit2 https://en.cppreference.com/w/cpp/experimental/parallelism https://en.cppreference.com/w/cpp/experimental/parallelism Visual Studio's official documentation uses the term functor as of 2021: https://learn.microsoft.com/en-us/cpp/standard-library/function-objects-in-the-stl?view=msvc-170 https://learn.microsoft.com/en-us/cpp/standard-library/funct... A simple Google search shows no shortage of recent websites and documents including fairly authoritative references using the term functor to describe a type that overloads operator (). Heck even the author of this article, Raymond Chen, uses the term functor as recently as 2020 to describe such a construct: https://devblogs.microsoft.com/oldnewthing/20200513-00/?p=103745 https://devblogs.microsoft.com/oldnewthing/20200513-00/?p=10... Is Raymond Chen not a C++ expert?
- sgbeal 2y ago> In C++ lingo they are called function objects or callables, not functor. The word "functor" has a long and glorious history in C++. Try entering "C++ Andrei Alexandrescu functors" into your internet search engine of choice. For bonus points, try "c++ Scott Meyers functor" as well.
- Maxatar 2y agoThe creator of C++ uses the term functor in the book "The C++ Programming Language" to describe any object that overloads operator ().
- layer8 2y agoIt's not like anyone has a monopoly on the term: https://en.wikipedia.org/wiki/Functor_(disambiguation) https://en.wikipedia.org/wiki/Functor_(disambiguation) The C++ usage was introduced by Jim Coplien in his 1992 book as a succinct name for an architectural pattern in C++: https://archive.org/details/advancedcbsprogr00copl/page/166/mode/2up?q=Functor https://archive.org/details/advancedcbsprogr00copl/page/166/...
- sham1 2y agoI'd argue that unit would be just as cryptic as monostate, if you don't know what either is. Like, if we assume someone looking at code with `std::unit`, what might they think this is? If one is not aware of its use in ML or similar, it could just as easily be assumed that it could be something to do with units like meters or kilograms or whatnot. After all, the C++ standard library is vast so it wouldn't necessarily be all that far-fetched. Then the only question would be to ask why it would be default-constructible. At which point you'd have to read the docs for the type anyway.
- lmm 2y ago> I'd argue that unit would be just as cryptic as monostate, if you don't know what either is. And if my grandmother had wheels she'd be a bicycle. Of course if there wasn't a standard name for this concept that had been used in the industry for 50+ years (and in theoretical work for over 100) then it wouldn't make any difference what name you used for it. But given that there is a standard name for this concept that has been used in the industry for 50+ years, making up a different name is pretty unfortunate.
- jcelerier 2y agoI mean, the industry is composed by much, much, much more C++ than ML programmers
- mananaysiempre 2y agoIt’s called “unit” because it is a unit of the operation of multiplication / constructing a tuple (up to a unique isomorphism): for any type 't the tuple types unit * 't and 't * unit are isomorphic to 't. When you don’t have that as a fundamental operation in your type system, like ML does, then it could be confusing.
- xdavidliu 2y agosure, but I would be surprised if a significant fraction of programmers knew that. When we hear the word "unit", that's not the first definition that comes to mind.
- Scubabear68 2y agoMy guess is the maintainers of C++ keep making it more and more awful in an attempt to force people to more sane languages. But to their dismay the crazier it gets, the more some people dig in and embrace it even more. /sarcasm. I think.
- andersa 2y agoIt's not sarcasm. The maintainers have completely lost the plot.
- IncreasePosts 2y agoEven Herb Sutter agrees(I think, in his heart, even if he doesn't come out directly and say it), which is why he is working on cppfront
- atoav 2y agoComing from other languages I noticed this about C++ as well. I can't give examples right now but I recall multiple times being like: "Oh that is just a weird name for $KnownComputingConcept".
- halayli 2y agoThe term "vector" represents an ordered collection of elements(ex 3-dim vector is [x,y,z]). A list is flat out incorrect because it is used to refer to linked list(std::list), and a collection means a group of objects and that can be anything like a map, set, etc so it's too generic. Before C++ popularized the term, other programming languages and libraries had already used "vector" to describe similar data structures. For example, Common Lisp has a vector type that represents a one-dimensional array.
- Maxatar 2y agoStepanov introduced the term in C++ and he fully acknowledges that it was a bad name and that he regrets it. If he could redo it, he would have renamed it array or array_list. Interview with him acknowledging this: https://www.youtube.com/watch?v=etZgaSjzqlU https://www.youtube.com/watch?v=etZgaSjzqlU
- Y_Y 2y agoIt doesn't help that mathematics and physics have their own overlapping but unequal definitions of "vector".
- microtherion 2y agoAs does Biology. And computing has interrupt vectors as well.
- yndoendo 2y agoReactive style programming also takes the Unit as the value to act upon when the value and the type does not actually matter and only the action does. https://stackoverflow.com/questions/54336641/is-there-any-reason-why-system-reactive-unit-wasnt-called-system-reactive-void https://stackoverflow.com/questions/54336641/is-there-any-re...
- gpderetta 2y agoConsider ML appropriating the term tensor...