I've noticed that sources of FASMG use both spaces and tabs:
Actually, I always use visible tabs and spaces (most editors allow you to display tabs and spaces), so I always notice such inconsistency. What's wrong with it? It just means that when tab size is different from the size in the author's editor, the formatting of the source code will look a bit broken, like on my previous screenshot. I suppose that the author uses 8 as the tab size, and it has to look like this:

The solution is easy. Just always use tabs for indentation and spaces for alignment. Such code will look nicely in every editor independently on tab size, and it is still will be possible to choose preferable tab size (for example, I prefer tab size = 4).

So, we are using tabs here (for indentation):

And we are using spaces here (for alignment inside lines):

For example, Notepad++ has a plugin (the TabIndentSpaceAlign plugin) which automatically chooses between tabs and spaces in different situations. So, it always uses tabs in beginning of any line, and spaces when any other symbols than tabs are on the left of the current line.

Description of the plugin:

Quote:

Support using tabs for indent and spaces for alignment. It does a couple things. First, when you insert a new line it will exactly copy the preceding indent, instead of turning tabs to spaces or vice-versa. Second, if you insert a tab anywhere in the indentation part of a line (which is considered to be from the beginning of the line to the first non-tab) it will insert a tab, otherwise it will insert spaces.

Some other editors may name such behavior as “Smart Tabs”, and it can be enabled in settings. And yes, you can always do it without any plugins, but automatic solution is better, of course

The schemes in my sources are made by the "Optimal fill on saving" option of "flat editor" (the editor core used in FASMW and FASMD). This option is inherited from the DOS Navigator's editor which "flat editor" tries to mimic in many features. The editor by itself does not use tabs at all, it just has a freely navigable whitespace. With this option turned on it automatically converts any area of whitespace into a sequence of DOS-sized tabs and spaces that makes the smallest file. Turning this option off makes the editor fill all the whitespace with spaces only, which preserves it better for other editors.

I think the point was that "Optimal fill on saving" is only optimal is the user also sets their tab size to 8. Any other value make the "Optimal fill on saving" not so optimal.

Yes, of course. This is a legacy of the DOS days when there was only one tab size for everyone. (And the "optimal fill" phrase is also a legacy, it was named this way in DOS Navigator.) If we allow variable tab size, the only way to preserve the exact whitespace structure is to not use tabs (only spaces) and this is what "flat editor" does when that option is turned off. Perhaps I should make FASMW have the "optimal fill" turned off by default, I don't know.

It is better to use tabs for indentation and spaces for alignment. It is more flexible.

In case of assembly language this distinction is not well-defined. It is usual to have at least a label column, instruction mnemonic column and operands column, and each needs to be aligned properly even when the previous one is missing. You can have label on the same line as instruction, sometimes you might even want to put an instruction prefix before the mnemonic column so that the main instruction is aligned with the other mnemonics (and not operands). Or you may split longer operand lists into multiple lines with "\" (and have a line that starts right at the operand column). Thus for a pure assembly language it just an alignment everywhere (note that the "smart tabs" feature, another one inherited from DOS Navigator, nicely fits into this). Though, of course, indentation shows up in case of macros and nested block directives.

Therefore the only real solution to the problem of "portability" of source text between editors with different tab sizes is to fill everything with spaces, preserving the exact measurement for every indentation and column alignment. And this is what "flat editor" does by default (but FASMW overrides it by turning the "optimal fill" option when initializing a new configuration).

Nah, that part is true. Indenting with spaces is better since the best indentation is 2 spaces, anything more is a waste. Plus, with tabs you can "customize" the indentation, even though no tab width is 2 spaces by default (so it sucks).

Customization is bad. People should be forced to read code indented with 2 spaces, whether they like it or not. Because it's smarter. Clearly my opinion is law.

That said, the article is pure bullshit, I mean really it said PHP and Perl? That's kind of ridiculous typo for Java and Python...

There seems to be an accepted wisdom that indentation is the "proper" thing to do, and that only the amount of spacing is in question.

But what if there is a better way? Instead of having indentation, as thus no arguments over how much indentation to apply, maybe something else entirely? Perhaps some sort of colouring scheme? A different font size? Or a different lead character that isn't whitespace, perhaps a bracketing layout? Maybe some combination of these?

But what if there is a better way? Instead of having indentation, as thus no arguments over how much indentation to apply, maybe something else entirely?

I've gotten so old and tired of the whole issue that I've just switched to using automated formatting tools whenever I can so that I don't have to waste time fine-tuning missing or extraneous whitespace. I much rather just select the block of text that needs reformatting, press a key combination and be done with it. Or tell the tool to reformat a bunch of files in place. After all why bother doing it manually if the machine can do it for you better and faster than you ever could? Just install the tool and tweak the default config file it dumps until things look the way you want. Unless you're doing something weird you don't need to tweak it more than once.

If all relevant tools would also understand and support automated formatting properly for both input and output then would people even need to be having this discussion for anything other than two people with different preferences viewing code on a shared screen?

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum