Having an asterisk both be the type indicator and the dereference operator is one of the great programming language design blunders of our time, along with allowing nulls for any type in so many languages.
Whitespace
Submitted 9 months ago by JPDev@programming.dev to programmer_humor@programming.dev
https://programming.dev/pictrs/image/6c0ae859-45c1-48ec-8e9d-2b5b4a552220.webp
Comments
GissaMittJobb@lemmy.ml 9 months ago
darkpanda@lemmy.ca 9 months ago
I also sometimes wish that the syntax in
if
statements was inverted, where()
was optional and{}
was required.CodexArcanum@lemmy.world 9 months ago
Rust makes this choice and it is way better.
victorz@lemmy.world 9 months ago
Based
clay_pidgin@sh.itjust.works 9 months ago
Cab you give me an example? I’m not sure I follow. Might be language specific?
Blackmist@feddit.uk 9 months ago
Having assignments return a value is right up there as well.
GissaMittJobb@lemmy.ml 9 months ago
Because of the possibility of accidentally performing an assignment in a conditional expression?
If yes, I agree that it’s not great.
dbilitated@aussie.zone 9 months ago
I’m just a c# dev wishing to fuck we had something visual to indicate reference types so my coworkers could stop misusing them
jjagaimo@lemmy.ca 9 months ago
stackoverflow.com/…/how-can-i-give-different-colo… might get you closer?
dbilitated@aussie.zone 9 months ago
oh thank you! I use jetbrains but I wonder if I can implement the same thing
vithigar@lemmy.ca 9 months ago
It’s such a short list of value types though. How can they have that much trouble? All of the various ints and floats, bool, char, structs, and enums. Everything else is reference.
fl42v@lemmy.ml 9 months ago
std::shared_ptr<int> p;
victorz@lemmy.world 9 months ago
Wait until I tell y’all about const.
exocrinous@lemm.ee 9 months ago
Int *p is unreadable, unreasonable, and bad programming.
Ferk@kbin.social 9 months ago
But the syntax clearly intends
int *p
.
Otherwise you would only need to doint* p, q
instead actually being required to type*
in front of every variable name when declaring that way:int * p, * t;
exocrinous@lemm.ee 9 months ago
That’s because C was designed by a fool.
Aatube@kbin.social 9 months ago
Why so? It’s what it actually is
catconnoisseur@lemmy.ml 9 months ago
no int * ptr fans here?
RandomCookie420@eviltoast.org 9 months ago
Ever written a entire php in one line? I did, and that without separation whenever possible.
Man my coworker even ended the trolling contest over that.
db2@lemmy.world 9 months ago
int * p;
kambusha@feddit.ch 9 months ago
Here is an otter
Image
otter@lemmy.ca 9 months ago
:)
Deceptichum@kbin.social 9 months ago
Male otters kidnap children otters and hold them for ransom until the mum gives them food.
thomasloven@lemmy.world 9 months ago
I’ve seen that in style guides ”because it should piss of everyone equally”.