Pascal Style Guide lazarus / 6-IDE-CodeTools ---------------------------------------------------------------------- Valentin · 2007-04-08 14:08 Hi all, The guys who create the code completion should take a look at http://dn.codegear.com/article/10280 For the time being the code has no space before and after assignment operator, arithmetic operators, etc. Maybe this is a small problem, but we must be accurate ---------------------------------------------------------------------- CCRDude · 2007-04-25 12:21 Why do we need to be "CodeGear-accurate"? Why not using GNU style? Or the Econos style? Or one of the other standards out there? ---------------------------------------------------------------------- Marc · 2007-04-26 09:48 you can configure the way spaces are used to match your taste. The writer of the codecompletion code doesn't like spaces ---------------------------------------------------------------------- Valentin · 2007-04-26 20:14 The reason of using spaces around operators is that the code is more lagible with spaces. Believe me. ---------------------------------------------------------------------- Marc · 2007-04-27 08:53 Yes I do. (I didn't write the codecompletion) ---------------------------------------------------------------------- Kunstbanause · 2008-10-20 12:56 Quote from: "Marc"you can configure the way spaces are used to match your taste. That's right. BUT: Using this result in a space character after/before brackets too. There should be an option to configure brackets and assignment/arithmetic operators independently. ---------------------------------------------------------------------- duncanparsons · 2008-10-20 13:22 I have much greater sympathy with the econos style, than I do Borland... I go further, and for greater legibility I would write Code: [Select]for i:=0 to 10 do   begin     if SomeArray[i]<10 then       begin         writeln(inttostr(i));         writeln('Array value less than 10');       end      else       begin         writeln('>'+inttostr(i));         writeln('Array value less than 10');       end;   end; I find that indenting like that makes it far easier to search structures, and makes the matching of begin/end pairs more obvious; and it makes ifs a whole lot more easy to navigate and work out what and else applies to. I worked for one company who used a style scheme that made absolutely no sense to me in terms of reading, which would render the above as: Code: [Select]for i:=0 to 10 do begin   if SomeArray[i]<10 then begin     writeln(inttostr(i));     writeln('Array value less than 10');   end else begin     writeln('>'+inttostr(i));     writeln('Array value less than 10');   end; end; Yes it's more compact, but that isn't necessarily a good thing. A quick read suggests too many ends, and nesting makes it worse! OOI, what did Wirth suggest? DSP ---------------------------------------------------------------------- Leledumbo · 2008-10-22 04:28 QuoteYes it's more compact, but that isn't necessarily a good thing. A quick read suggests too many ends, and nesting makes it worse! Just a matter of style, I guess. I prefer this to the previous one because it's more compact and less indented. Nesting with previous style would lead to: Code: [Select] if Condition then   begin     if AnotherOne then       begin         DoSomething;       end     else       begin         DoSomethingElse;       end   end else   IGiveUp; Compare with: Code: [Select] if Condition then begin   if AnotherOne then begin     DoSomething;   end else begin     DoSomethingElse;   end; end else begin   if AnotherOne then begin     ICanNestMoreHere;   end else begin     OrHere;   end; end; Plus, I can avoid having semicolon before every else because it can be easily noticed. ---------------------------------------------------------------------- Zaher · 2008-10-23 15:37 1- Code: [Select]   if something then     dosomehing;   if somthing then   begin       somthing;   end; compare with 2- Code: [Select]   if something then     dosomehing;   if somthing then begin       somthing;   end; in 2 you need your eyes recognize the tab before second IF for decided it is not nested in first if compare with 3 - Code: [Select]   if something then begin     dosomehing;     if somthing then         somthing;   end; ---------------------------------------------------------------------- duncanparsons · 2008-10-23 20:25 It's taste, as has been said. And what ever you use, be consistent.. a great article on it is http://www.joelonsoftware.com/articles/Wrong.html DSP