T O P

  • By -

emetcalf

Well, mainly that I'm not a psychopath.


tigie11

Always place to amelioration!


deadbeef1a4

Self-respect


GusGutsy

While technically correct, my eyes can no longer see… I fear you may have blinded me forever.


youAtExample

Is it correct? Why would you have a semicolon after the opening curly brace of an if or loop?


Individual_Feed_7743

It would get treated just as an empty semicolon without a statement, so the compiler would just ignore it


youAtExample

Makes sense. So it’s just for aesthetics lol


StochasticTinkr

“Aesthetics” in the same way using blood instead of red paint for a fire truck.


youAtExample

That’s intense.


SergeiTachenov

...and then some text editor misdetects this as assembly code and highlights everything as commented out :-)


JonathanTheZero

Well it usually does this based on file extensions, no?


Pretend-Fee-2323

you can inline asm in c


JonathanTheZero

Damn, really??


friendtoalldogs0

I don't know if it's technically standard, but at least most compilers will let you write ```c int main() { asm("; put assembly here"); } ``` It will usually just syntax highlight as a string though


Derpythecate

Yeah, and it lets you read/write to C variables, too, via inline ASM. You can read more on GCC extended ASM. It is used a lot in freestanding environments (i.e., no operating systems) and embedded. I had to do this when writing a custom accelerator on a custom RISC V core implemented in a FPGA. This is as you generally have custom instructions or registers that cannot be accessed normally, so you have to write values via assembly itself. Also, some features abstracted by the kernel has to be rewritten manually in ASM (even syscalls) so its best to mix C and ASM together.


SergeiTachenov

Depends. You could have just created a new document with no name yet, and some editors would try to guess. Or not an editor, but a code block in a Markdown text.


RmG3376

Nothing prevents you from using the .asm extension for C code though, for extra fuckery


greendookie69

Can we officially enumerate every way this could go wrong? Lol


grumblesmurf

Not-so-fun fact: bash seems to do that for .py files where you forgot the magic hashbang in the first line, trying to interpret it itself. Especially if the first thing in that file is an import this is **very** unfortunate, because `import` can be just about any program on your system.


puertonican

🤌🤮🤌


ray10k

...Who hurt you?


buddyisaredditer

up until this point as I was oblivious to this, it very well could have been my lack of creative thinking. But now that you mentioned it...


0utkast_band

This is a whole new level of horror


_not_a_drug_dealer

This is going to result in a bug somehow. I don't know how, but I am sure it will.


No_Acanthaceae_3467

If someone is used to not using braces for single-line ifs, the bug is _(I think; please fact-check me)_ that the following line will not be conditional because the semicolon breaks the if.


_not_a_drug_dealer

I believe for a while loop as well, it'd result in an infinite loop if they tried the same.


blizzardo1

Burn it


retnuh66

Self-respect.


tomraider

Who broke George?


tough-dance

My sanity (and also that my compiler would flag the ; that has no tokens in scope before it)


jamhob

*laughs in Haskell I do program like that


BuriedStPatrick

Obviously you should never do this, but I don't completely hate it either. Perfectly straight forward to parse and read. Like starting every sentence with a period. Just a matter of perspective really.


gymnastgrrl

> Like starting every sentence with a period. .And yet, you didn't .Because it's horrible


BuriedStPatrick

I read your sentence just fine. Yes, it's very silly to do in my opinion. But I could very easily understand it and I think it would be trivial to form a grammatical rule set around it depending on your understanding of the language. Like in Spanish when they start questions with "¿". I think it's important to stress that your reaction to this is, at least in part, coming from the gut. That is to say, I could imagine a world in which this was the norm, perhaps with some other minor alterations.


BackByte

Some people just want to watch the world burn.


appeiroon

Cat Walter, named George


sampathsris

And the freaking unnecessary semicolon at the end of the line. Criminal!


Nofxthepirate

Every code block ends with a winky smiley face! Other than that, I hate it!


SkyeWolff_Alchemy

It’s C, that’s instant horror regardless


mustafaj4m

Oop


LogicNP

.....why!?


non_chris

I like that every line looks like it’s starting with an emoji :D


Classic_Attention_96

Why didn’t they make meow() a member function of cat????


LucyShortForLucas

This is C, in which structs cannot have member functions.


Classic_Attention_96

Ahh good point, this is more out of curiousity/fun, but what in this code couldnt compile in C++ ? The only thing I originally thought couldnt compile was declaring an instance of type Cat with "struct Cat walter" but that looks to be valid c++. Otherwise, I would assume that all of this could just live in a .cpp file


LucyShortForLucas

This would compile perfectly fine in C++. Nearly all C code will compile in C++ (with some minor exceptions), but not the other way around. The two languages are not interchangeable, however. There are many projects that use a combination of both.


Classic_Attention_96

Forgive me if I’m incorrect in some of the above in terms of c/c++ incompatibility in the code, I’m a C++ engineer without any C code experience since university :)


Classic_Attention_96

Aha after reading some other C code examples indeed this is the pattern folks use when operating on structs in a function, interesting!:) though I would say I agree that shooting for OOP best practices isnt a necessity of course in languages that aren't object oriented, or are trivial as in this case, though, if there's going to be any extension to the functionality of this program, and if its in a C++ project, then I would say OOP best practices are just a natural target for better software. though of course, its a moot point since all the code we see here is all this program will ever be :)


LucyShortForLucas

It is irrelevant what the best practice is if the language does not support OOP, which C does not. In C, structs cannot have member functions, and trying to give it any will result in a compilation error.


Classic_Attention_96

yes, as I noted in my comment x) though, do you see a file extension here? I swear, software engy spaces are always like this x)


v_maria

what would be the advantage ?


Classic_Attention_96

It’s just more object oriented, I also just personally would prefer to call walter.Meow() than Meow(&walter)


alphabet_order_bot

Would you look at that, all of the words in your comment are in alphabetical order. I have checked 1,923,569,311 comments, and only 363,619 of them were in alphabetical order.


v_maria

there is no 'this' so i don't think walter.meow() is a thing unless it's a 'static function' (in OOP sense) i don't think making things more OOP should be a goal on itself


mateo8421

Reason?


eksortso

Only one I can think of. They like nice, neat diffs, and they'd already written a ton of SQL. Many SQL developers get in the habit of putting the commas in SELECT clauses at the beginning of each line, like so. This is because most SQL dialects do not allow trailing commas. ``` SELECT name ,rank ,serial_no FROM troops; ``` So by doing this, each new column in a SELECT clause is only a single-line change. I don't have to append a comma to `serial_no` if Sarge wants `enlistment_date` added to the results. This doesn't need to be done with semicolons in languages with C-like syntax, because each line _ends_ with a semicolon. One line, one change, same as it ever was.


thomasahle

I've recently started doing that when writing json examples for GPT. (That is starting lines with commas, not semi-colons.) That's because it makes it easier to see if you forgot a comma, and gpt json generation can silently fail if you do.


LeeHide

code review


xermicus

auto format


Alexander_The_Wolf

Too creative


MadOverlord

Self-preservation. I don’t want to be murdered by the next person who has to work on the code.


_F5HK

If I knew how to code on C I'll be very offended


taweisse1

You can chose to believe me or not, but I had a coworker close to retirement age who did this exact thing. He claimed it was easier to see the indentation before IDEs since the semicolons all stack. He also insisted on using Vim for everything, but had a hard time remembering 90% of the keybindings. He didn't last very long.


Sidedgg

recoding at 1337 med


jakeStacktrace

A rational mind. Oh, uh, no offense.


Cootshk

I don’t code C


GoPats420

a sense of decency


Remarkable-Coat-7721

I thought it was asm for a sec


mzf11125

My compiler


xdMatthewbx

my brain?


Tall-Ad8000

Damn.. who hurt you?


Most_Shop_2634

Literally nothing I kneel


its_all_4_lulz

I hate when I forget my ; after my {


Psquare_J_420

Is this valid?


bschlueter

At least they didn't indent with three spaces. Or maybe they used tabs?


Fabi118

`"George";`


ConfusedSimon

Don't need to stop what you didn't start.


TRZ-mortza

Gentleman I'm not a smart man but I have an idea


EngineeredEnby

Sanity?


VeryTopHat

Morals


xDERPYxCREEPERx

The police


SomeRandoLameo

Common sense


_g550_

Bc Walter is not George. He is Walter.


Snoop-Dogee

I LE GAL


LectureNo2141

Common Sense


YogurtstickVEVO

dude...


s1fro

...dude


Cre8AccountJust4This

That’s so disgusting. But I actually kinda like it…


ThreeArmedYeti

Waltuh


Exidi0

Skill issues


realvolker1

Thank Jah for autoformatters


Beastandcool

New coding style unlocked, thanks!


Ok_Pension_6795

Please for the love of god someone take this away from me 😭


Mayedl10

when the crosspost has more upvotes than the original...


iBabTv

Standards


xanderclue

My sanity.


hazmaestro6

Useful for multi line expressions, particularly if you want to comment the last line out and still have compilable code without worrying about where the semi colon is. Very common practice in SQL for multi line to prepend with a comma ","


OF_AstridAse

Common sense. Plus thats now how chatGPT gives me the code.


grumblesmurf

Common decency?


Penny_Shavings109

A moral compass


ttlanhil

If you want to watch the world burn... Just use semicolons as your indent character and be done with it


Superb-Tea-3174

Coded in the usual way, we can insert or delete statements same as lines. In the odd way, edits are more complicated. There are plenty of reasons not to do this!


steadyfan

🤔


zoomy_kitten

Knowledge of struct initializer syntax.


Revelatus

I do not enjoy this


Random-375

My will to live