Code Monkey home page Code Monkey logo

Comments (3)

DJPlaya avatar DJPlaya commented on June 16, 2024

Hi,
You where the last one i where expecting to see when opening this Issue, glad to see you caring about your Projects even after soo many Years <3

There is no need for Semicolons since the default Compiler Value is 0. I still place it behind everything except for: if/else/case/switch/function names/block lines like { } - just because, there is no good Reason, just me being Autistic ^^, but youre right, i probably should remove them from all 1.8+ Projects

I try to make an consistent Codestyle, ive documented the basics over my other Project > https://github.com/DJPlaya/Kigen-AC-Redux/blob/master/CONTRIBUTING.md

When comparing the original V1.73 Code with the latest Redux Commit, i can see the following Changes which i will ref. from another Project for easy Access:

from forlix-floodcheck-redux.

Forlix avatar Forlix commented on June 16, 2024

I admit I may have an unusually compact coding style and I'm coming from C/C++ (which is my favorite language), that should give you some perspective. That's also why I embraced the semicolon in all of my SourceMod projects because it gives you more freedom and in my opinion allows you to write more concise and more readable code. I often split up conditional statements onto multiple lines instead of putting everything in a single line - the latter to me just looks cluttered and harder to read. As the code was originally written with mandatory semicolons enabled, there had to be a semicolon after the "while", because the "while" was part of the "do" block.
As a matter of fact, I believe I actually wrote this function in Visual C++, using its debugger to step through the code. Once it was complete and working I simply copied it over to my plugin, replacing just the C-style declarations and function prototypes. Nowadays and to my delight SourceMod even uses the C-style declarations which would have made this even easier.

Your code definitely looks better now, although I'd remove the empty line 185 just to make it clear that the "while" is part of the block above it (if your styling guidelines permit). That's the advantage of semicolons - looking at your code now, one might come to the conclusion that the "while" actually loops the assignment beneath it (with an awkward empty line in between). With semicolons you would start to wonder if it was just an empty loop (rare) or maybe look up to realize it is part of a "do...while".

Hopefully that answers your questions. By the way I am not sure how experienced a programmer you are, but your rule of not placing a semicolon after those things you mentioned should be rooted deeper than "no good reason". The semicolon (in C, and in SourceMod, if enabled) is not just something put at the end of a line for fun. It is used to terminate a statement. If you were to write "if(...); something" then "something" would always be done because it would not be part of the "if".

Take a look at the Wiki for SourcePawn (that's what the language for SourceMod plugins is actually called):
https://wiki.alliedmods.net/Introduction_to_SourcePawn_1.7#While_Loops
Note that they use semicolons in all the examples there and I also warmly recommend you do too. It helps a lot to avoid errors and ambiguities in the code if you use "#pragma semicolon 1". The compiler warnings should be your friend, not your enemy. You would have been made aware of this issue by the compiler and could have resolved it on your own.

from forlix-floodcheck-redux.

DJPlaya avatar DJPlaya commented on June 16, 2024

I am aware of the previous Usage of the Semicolon, its kind of a Leftover from converting since ime still learning with my Projects.
I mainly left it for readability since many Coders dont like the 1.7/1.8 Change, but its a good Idea to use it for catching some typo Errors.

from forlix-floodcheck-redux.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.