• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Create Basic Commands
#3
(2019-04-18, 08:05 AM)Alaska Wrote: The code looks worse the way you write it because you use brackets just for a single "return" statement and leave absolutely no spacing in between.



From a post I wrote a while back:



Quote:Not using braces around single line statements is a bad habit that can make your code more prone to human errors. You might be interested in reading about Apple's gotofail bug. The PAWN style guide by Southclaws states the following:?



Quote:Blocks must always use braces, even if only a single line of code exists within a block. This applies to all levels including functions.



This style guide is indeed unofficial, but is approved by many reputable scripters in these forums and is the closest what we have to generally accepted and/or official code standards at the moment. It is based on years worth of knowledge in other programming languages, as well as their standards. Barr Group's Embedded C Coding Standard book, which can still be a good reference here due to PAWN being a language with a C-like syntax, states pretty much the same as the PAWN style guide:



Quote:Braces shall always surround the blocks of code (a.k.a., compound statements), following if, else, switch, while, do, and for statements; single statements and empty statements following these keywords shall also always be surrounded by braces.



However you are correct about having no spacing, I'm a sucker for whitespace myself. The tutorial itself... tl;dr for now, but it seems okay at the first glance. You might want to use [php] tags instead of [code] tags and use Courier New font for inline?code?instead of surrounding them with backticks (``) though.
  Reply


Messages In This Thread
How to Create Basic Commands - by DTV - 2019-04-18, 01:50 AM
RE: How to Create Basic Commands - by kristo - 2019-04-18, 12:56 PM
RE: How to Create Basic Commands - by DTV - 2019-04-18, 06:49 PM

Forum Jump: