[Lazarus] Elastic Tabstops: benefits or not

Graeme Geldenhuys graeme at mastermaths.co.za
Fri Nov 6 16:02:43 CET 2009


Again in the attached image, Tab characters are shown as pink dots.


Martin wrote:
> 
> but I do not see how the increase portability between editors

Lazarus is my editor for development work - personal and company
projects. Hopefully Lazarus is the editor other developers & companies
too, otherwise what are they doing in this mailing list. ;-)


> Elastic tabs (or source containing tabs, that should be displayed as 
> elastic tabs) only display correct if the editor is set to elastic
> Tabs with width 4 only display if the editor is set to width 4

"elastic tabs" should read "elastic tabstops". A Tab character ($09) is
just that, a charter. And that is not very "elastic" at all. :-)  This
information comes directly from the "Elastic Tabstops" website.


> Both of them break, if the editor is set to anything else.

No, if the editor uses elastic tabstops feature, code is a lot more
"visually portable" between other editors using elastic tabstops
feature. By this I mean, each developer can customize there tabwidths
and padding, and all alignment will still be correct.

This is not the case with standard tabs where that have preset tab
widths and specific column positions.

NOTE:  All this only applies if you use Tab characters in your source
code. This does not apply if you convert those tabs to spaces etc...


> Elastic tabs, as any other tab, force all user to have the same editor 
> setting.

Nope, see above.


> That is not equivalent with better portability.

Portability is achieved if your company decides that all source code
files contain tabs and uses elastic tabstops feature. Is like example
the same as if your company decides on a specific code formatting style.

Portability is also achieved if for instance I use elastic tabstops
feature in Lazarus source code, but when I save the IDE source code
changes I made, I do a conversion from Tabs to Spaces. Because the
Lazarus project uses spaces in there source code.


> And also: this (alignment of tabs) does not require elastic tabs, this 
> requires tabs with 2 kind of settings:
> - indent for leading tabs
> - fixed pos for tabs in the middle of the line
>  (e.g all tabs in the middle of the line align to column 80)

That cannot work, as I have show in my first message. What if parameter
values must be aligned, or a record structure. I don't want those to
start at column 80! And the usage of tabs there, are not just for adding
comments, but for code alignment.


> ex1.png (aligning params in a multiline procedure declaration), raises 
> another serious question (but nothing to  do with portability)

It's a matter of code formatting rules, and if you have complex
parameters that you want to comment inline and not via a external help
tool like fpdoc.


> I thought elastic would apply to tabs that are "not leading" that is 
> tabs that are in the middle of text.

No, leading tabs act like normal tabs. Jump a set number of pixels (or
characters), depending on the ET implementation. One difference being
that if alignment was used (non-leading tabs) in previous line of code,
then alignment occurs and the tabwidth is different to a standard tab.

Line 2 in ex3.png shows that.


> If it applies to tabs that are at the very start of line: How do you 
> indent after a  "begin"? Because the indent should not  depend on the 
> previous line?

It depends in which "tab block/cell" it falls into. The ET website
explains tab blocks/cells with a image.

See lines 15 vs lines 18 in image ex3.png. Elastic tabstops wants to
align content with tabs. On line 15 there is no point in adding the
second tab before the comments. Because what do you want to align the
comments with? Nothing, so use a space to separate the comment from the
code, as is done on line 18.


> - begin should do
>  if a then begin => // some comment
>  => writeln('a is true');
> 
> Writeln should be indented by 2,3 or 4 / but not aligned with the 
> comment of the previous line

As I said, tabs help with alignment. Do don't want to align the comment
with anything, so use a space character instead. This is exactly the
same rules as what you have done with the space between "then" and "begin".




Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex3.pas
Type: text/x-pascal
Size: 356 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20091106/d56e7ad8/attachment-0002.pas>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex3.png
Type: image/png
Size: 8624 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20091106/d56e7ad8/attachment-0004.png>


More information about the Lazarus mailing list