[fpc-pascal] Underscores in numerical literals - grouping

J├╝rgen Hestermann juergen.hestermann at gmx.de
Mon Nov 21 17:05:16 CET 2016


Am 2016-11-21 um 15:46 schrieb Graeme Geldenhuys:
> The age old rule
> of programmer source code always being in a mono-spaced font is
> ridiculous for this day and age.
>
Why?
I like monospaced fonts for code very much.

Code is not a novel or a newspaper where you read
a lot of text from top down to the end in a linear manner.
Instead, alignment is very important to make code more readable.
Monospaced fonts make it much easier to align code and
make a lot of things align 'automatically'.

I even align procedure headers like the following where all variables and
all types start at the same column
(which may not be visible in this email if you use proportional fonts ;-).
Please copy it to notepad or into Lazarus Editor in this case):

---------------------------------------------------------------------
procedure TForm1.FunctionListGetHintSize(Sender : TBaseVirtualTree;
                                          Node   : PVirtualNode;
                                          Column : TColumnIndex;
                                      var R      : TRect);
---------------------------------------------------------------------

and I align the 'MaskFilter' variable in such a for loop:

---------------------------------------------------------------------
for i := Low (MaskFilter) to
          High(MaskFilter) do
---------------------------------------------------------------------

and I like such an aligned declaration

---------------------------------------------------------------------
function  FileCompareName     (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareDate     (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareSize     (Datei1,Datei2 : PFileTyp) : SizeInt;
function  DirCompareFilesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareBytesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInDir     (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInBranch  (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirName       (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareFilesInBranch(Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareBytesInBranch(Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInDir    (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirName      (Dir1,Dir2 : PTreeTyp) : SizeInt;
---------------------------------------------------------------------

much more than a non-aligned:

---------------------------------------------------------------------
function  FileCompareName (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareDate (Datei1,Datei2 : PFileTyp) : SizeInt;
function  FileCompareSize (Datei1,Datei2 : PFileTyp) : SizeInt;
function  DirCompareFilesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareBytesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInDir (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirsInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  DirCompareDirName (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareFilesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareBytesInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInDir (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirsInBranch (Dir1,Dir2 : PTreeTyp) : SizeInt;
function  TreeCompareDirName (Dir1,Dir2 : PTreeTyp) : SizeInt;
---------------------------------------------------------------------

You can see imeditately that many functions have the same parameters and all result in a SizeInt.
In the non-aligned version this is harder to spot.




More information about the fpc-pascal mailing list