You jest, but there have been serious proposals to be able to overload the dot operator for uses such as with smart pointers (by Stroustrup and Dos Reis no less) for smart references and proxies, which (per this post's title) would enable some occurrences of -> to simply use . to access the fields. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4173.pdf
Also, apparently the graphics proposal is going forward with making the whole thing constexpr. This will allow things like compile-time rendering of SVGs into bitmaps, and (ultimately) compile-time dialog boxes that let the programmer configure a library using simple graphical options, instead of using all those hard to use, barely documented #defines we now use.
I feel like each subreddit needs to just pick one April fools, allow that and remove any extra ones. Between tech and the regular news I feel like I just waste half my April fools reading incorrect articles. I'd rather waste my April fools reading legit articles.
I actually agree that more distinctiveness would be good; I think with current default fonts I do like yours more. But to the extent this is a serious discussion in the first place, I'd rather use what I view as the "correct" character and let the fonts catch up in distinctiveness, which I definitely think would soon follow if this were adopted by a widely-used language.
It's too bad they cant make this proposal work.. well, except for the object and the gc stuff. I'm sure the compiler could figure out whether . should be -> or :: in 95% of cases but it's those edge cases where it gets it wrong...
It's necessary when there's an operator->(). Take std::optional<T> o;, for example. o. refers to the std::optional itself and o-> refers to the T it contains. Being able to do this sort of thing with an operator rather than a getter member function is much more elegant.
Why couldn't one still define operator -> even if the compiler normally replaces . with -> where appropriate? Would the determination of 'appropriate' get too complicated?
This would mean :: if string was a namespace or string was a static variable, it would mean -> if std was for some reason a pointer, and it would mean . if std were a structure or class reference.
I'm sure though some clever fool has some use case where you cant determine what is meant in context
No, what we need is a new initialization operator: <=, with its own set of rules. This will supercede all previous initialization methods, to "simplify" things.
You would probably be stuck with a conservative GC that just leaks like a sieve or end up having to handle hundreds of special cases. A std string could contain three pointers or 24 chars, some non standard strings have a length prefix but pretend to be C strings by giving you a pointer with a four byte offset. Some software abuses the fact that you generally don't have 64 bit of address space or that allocated memory tends to have some minimal alignment and encode metadata in the unused bits of pointers. Then you have software that just stores everything as a double NaN value, because why not!
I fear for the sanity of anyone attempting to write a generally useful GC for C++.
Managed C++, C++/CLI and C++/CX come to mind as three possible reference implementations of using GC in C++ (yes they aren't C++11 GC compatible), alongside Unreal C++ GC as yet another example.
But since haters gone hate, those of us that want GC in C++ are better off in C# and D regarding the community acceptance of such features.
The main problem seems to be that the current GC support is basically useless and under specified. Keeping it in the standard probably does more to block future attempts to fix the issue than it does to encourage GC implementations.
D
Wasn't "D as better C" born from the complete failure to support D without GC? It basically suffers the reverse problem. C++ programmers assume that they can mess around with pointers as long as they manage the lifetimes, which limits general use of a GC, while D assumes there is a GC to manage the lifetimes and can't handle object lifetimes without one. Note it has been some time since I read about that topic so my memory might be rusty.
regarding the community acceptance of such features.
Someone has to write a decent proposal and push it. The last proposal apparently got through despite being completely useless and without a reference implementation. So there can't be that much push back.
D, and C# (as of version 7.x and newer) to a lesser extent, also have ways to do GC free coding, in classical C++ so to speak.
In D you can mark code as @nogc, and they are in the process of having lifetime support as well, so that dataflows where the compiler can understand the complete lifetime, the GC doesn't come even into play.
In C#, you can ask the runtime to not execute the GC in a specific region, stack allocation for arrays is now also available in safe mode, there are more value type scenarios where structs can be used, using has been improved to work on any type that provides a Dispose like method (no need to implement IDispose and it can be an extension method), structs can be copied around with what is like const& with RVO, there is span support including native heap, allocation free pipelines.
I guess the problem is not having a decent proposal, it is having a thick skin for everything that might be thrown at it, graphics proposal style, so in the end it is easier to be around communities that are more welcoming to having some form of automatic memory management in the language, and leave C++ for the native libraries bindings offered by OS services or GPGPU programming.
In D you can mark code as @nogc, and they are in the process of having lifetime support as well, so that dataflows where the compiler can understand the complete lifetime, the GC doesn't come even into play.
As I mentioned my last info on that is a bit rusty, last time I checked they couldn't get classes to work without a GC.
In C#, you can ask the runtime to not execute the GC in a specific region
If that is enough to get a language the "doesn't need a GC" stamp then having a boehm GC should get C++ the "world class GC" stamp of approval.
See, that is the kind of anti GC-feeback I was talking about.
Instead of constructively look at what is actually available, snippets of my comment get desconstructed while reading the full context or spending some minutes looking at MSDN or D docs.
What hope can someone have when submitting a GC related proposal? Just to be linched by the mob even worse than what happened with the graphics API, while network, IO and filesystem get special treatment.
So we just bit the bullet and embrace the communities that see GC in another light,
D has something which is usefull for this. A T* myInternalPtr; alias this = myInternalPtr; declaration, which allows transparent mixing access of class/struct fields with its members and conserve type safety and access rights. (see dlang wiki)So no bullshit UB. Turns out this is also really powerfull for composite types and changes all smartpointers to easy to write composite types.
Better composition and easyer templates because template authors don't have to think "is this a reference, value or ptr" anymore and be forced to use different syntax. Having access forms being defined in the template signature on one spot significantly simplifies this.
And just because of some hypothetical convenience, you are eager to throw away concepts, which are there to show clear intent. I write template libraries, and figuring out what exactly you pass and making sure that it's passed as-is and it works, is part of my job. You shouldn't have an excuse to be lazy. Also the only syntactical difference would be with the pointer. But you can easily check if the type is a pointer. Replacing the scope resolution with an operator.() is an abomination, and it's plain stupid. It totally disrespects the idea of the scope resolution operator. Replacing the arrow operator is also just plain stupid. These operators show code intent. When I see a scope resolution operator, I know it's meant to acces a namespace member. When I see an arrow, I know it's meant to be a pointer. And if these things get replace with a dot, I need to read a lot more code just to understand the author's intent. That far outweighs the rare case of needing to check if the parameter is a pointer or not
Also, I'd personally only want . and -> to be thesame. I don't care about :: that much. I'd argue it simplifies about 50% of template functions and automatically make em universal.
You shouldn't have an excuse to be lazy.
Why not?
Also the only syntactical difference would be with the pointer.
All templates which could work with reference types can now magically work with pointers through this one small hack. Language purists hate him. Learn his secret on ....
These operators show code intent.
Allright I get that, but then use * if you're really keen on showing every pointer dereference. Just a question. How do you show intent that you're actively dereferencing a type and calling a function on a reference type? Why is this an issue? C++ doesn't really show this cut and dry anyway!
And if these things get replace with a dot, I need to read a lot more code just to understand the author's intent.
One single line. The function signature. It shows value, reference, forward references and pointers. That's already the only real way to distinguish between value, reference and forward references so you probably look at it in a reflex when reading the code.
That far outweighs the rare case of needing to check if the parameter is a pointer or not
I'd argue it does not. It simplifies code by removing 4 cases and consolidating them to 1 universal codepath.
3
u/Dan_Esp Feb 14 '22
Gotta combine this with the new unicode operator overloading for maximum effectiveness.
373
u/[deleted] Apr 01 '21
That would be terrible. My mood increases every time I use the -> and ::, I find them cool
174
u/bsdooby Apr 01 '21
object<-function
84
u/be-sc Apr 01 '21
Rather obvious, isn’t it. :)
82
u/[deleted] Apr 01 '21
Let's just use object➡️method()
212
u/UnicycleBloke Apr 01 '21
I'm still waiting for whitespace overloading.
68
u/stilgarpl Apr 01 '21
They should replace :: and . with ->
Arrows look cooler.
35
u/fdwr fdwr@github 🔍 Apr 01 '21
You jest, but there have been serious proposals to be able to overload the dot operator for uses such as with smart pointers (by Stroustrup and Dos Reis no less) for smart references and proxies, which (per this post's title) would enable some occurrences of
->to simply use.to access the fields. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4173.pdf35
u/systmshk Apr 01 '21
You nearly had me rage quitting back to C.
34
u/[deleted] Apr 01 '21
I was horrified for a brief moment
22
u/johannes1971 Apr 01 '21
Also, apparently the graphics proposal is going forward with making the whole thing constexpr. This will allow things like compile-time rendering of SVGs into bitmaps, and (ultimately) compile-time dialog boxes that let the programmer configure a library using simple graphical options, instead of using all those hard to use, barely documented #defines we now use.
16
u/Zanderax Apr 01 '21
God I hate April fools day. This stupid article is just a waste of my time.
14
u/Amablue Apr 01 '21
This seems like a strange addition given that they're also adding unicode operators like foo→function()
12
u/PrimozDelux Apr 01 '21
Personally I love arbitrarily writing . and -> until the compiler stops complaining.
17
u/aitvann Apr 01 '21
:: operator is the coolest thing about c++ syntax
8
u/thatguyonthevicinity Apr 01 '21
lol from what I see not only me that's horrified for a moment and was like "wh...what?"
7
u/Wacov Apr 01 '21
If null pointers are so bad why don't we just automatically increment them by one?
6
u/AmenBrother303 Apr 01 '21
Well, I'm an absolute speng; I just realised the date.
6
u/Elynu Apr 01 '21
Agrhhhh, you got me till the very end
5
u/LuisAyuso Apr 01 '21
Arg... got me
5
u/Ok_Calligrapher_6744 Apr 01 '21
It's April fool's again
4
u/[deleted] Apr 01 '21
I thought they had decided on the ` for that. Make up your mind jeez
4
u/gc3 Apr 01 '21
It's too bad they cant make this proposal work.. well, except for the object and the gc stuff. I'm sure the compiler could figure out whether . should be -> or :: in 95% of cases but it's those edge cases where it gets it wrong...
4
u/WadeReden Apr 01 '21
Bruh I actually fell for this shit for a solid 20 seconds.
13
u/bentheone Apr 01 '21
Thats a joke right ? Because 1st April n stuff.
4
u/[deleted] Apr 01 '21
Some day C++ will evolve into python with {}
2
u/genreprank Apr 01 '21
Thanks for reminding me that I shouldn't be on reddit today.
2
u/Rasie1 Apr 01 '21
Add operator->(int) for specifying indirection levels
a->b => (a).b a-->b => ((*a)).b a----->b
2
u/WoahHeFresh Apr 01 '21
ew don't do that
2
u/rsjaffe Apr 02 '21
No, what we need is a new initialization operator:
<=, with its own set of rules. This will supercede all previous initialization methods, to "simplify" things.1
u/Igoory Apr 01 '21
This is so stupid that I'm sure this is an April Fools joke.
1
u/genghiskhan__ Apr 02 '21
i am still learning modern C++ and seriously considered to quit after seeing the title of this post, phew, luckily it's a joke lol.
1
u/DesertXGhost Jun 04 '24
Blasphemy!
1
u/nintendomasters Jul 15 '24
std.cout would be insane. I am NOT going to use that idc what anyone says.
1
u/Vladislav20007 Nov 24 '25
-> could be replaced, but not ::. also, cpp is about stability, not design.
1
u/purebuu Apr 01 '21
jai would like to have a word with you
1
u/mmixLinus Apr 01 '21
This got me livid, then I checked the date.
1
u/k4lipso Apr 01 '21
i dont even have to read the article to know it is an april fool
1
u/lead999x System Software Developer Apr 01 '21
Lol good one.
1
u/plaferriere Apr 01 '21
...anyone check the date?
1
u/G6L20 Apr 01 '21
Is this an April 1st fact ?
1
u/chessset5 Apr 01 '21
Yes please.
1
u/BeigeAlert1 Apr 01 '21
Damn it all... got me...
1
u/cvnh Apr 01 '21
It's April fools, right?
1
u/iwalkwounded Apr 01 '21
wtf is up with the thumbnail image lol
1
u/Logonochi Apr 01 '21
April fools?
1
u/5pectre5 Apr 01 '21
rofl
1
u/aniketsinha101 Apr 01 '21
;-><-;
1
u/percocetpenguin Apr 01 '21
This has to be an april folks joke.
1
u/R4ttlesnake Apr 01 '21
I was panicking then I realized the date
1
u/green_meklar Apr 02 '21
You almost had me for those first few paragraphs...
1
u/jepessen Apr 03 '21
So what if there's a std::shared_ptr<MyClass> when MyClass has MyClass* MyClass::get() method?
1
u/[deleted] Apr 03 '21
NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO /s
1
u/TheCryoVProject Apr 05 '21
The garbage collection part though.
1
u/stomah Mar 23 '22
or even better, make them interchangeable
1
u/[deleted] Jan 13 '23
Why :(
1
u/nyanpasu64 Apr 01 '21
got my hopes up for a second
1
u/idaho7777 Apr 01 '21
That's foolish....
0
u/msew Apr 02 '21
slow clap
0
u/[deleted] Apr 01 '21
[deleted] — view deleted comment
0
u/[deleted] Apr 01 '21
[deleted] — view deleted comment
0
u/[deleted] Apr 01 '21
[deleted] — view deleted comment
1
u/[deleted] Apr 01 '21
[removed] — view removed comment