[erlang-bugs] erl_scan counts white space badly

Ulf Wiger ulf.wiger@REDACTED
Mon Jan 25 20:20:19 CET 2010


Robert Virding wrote:
> 2010/1/18 Hans Bolinder <hans.bolinder@REDACTED>:
>> [Ulf Wiger:]
>>> I tried the column tracking functionality of erl_scan:
>> ...
>>> The original source code wasn't misaligned, but the indentation
>>> used a mix of tabs and spaces. erl_scan treats all kinds of
>>> white space as one space.
>>>
>>> I think it would be reasonable to at the very least increment by
>>> 8 if it's a tab. Supporting a tab length option might also be
>>> possible, but then it would also be nice to have e.g. epp support
>>> passing of this option to the scanner.
>> We will consider adding such an option in a future release.
> 
> I would argue that it is not really the function of the scanner to do
> this type of thing as there are too many different options if it is to
> be supported properly. As the option 'return_white_spaces' exists it
> can very well be left to the caller of erl_scan.

Well, as it currently works, it tracks the column number,
so I wasn't asking for that particular feature to be added.
But if it's going to track the column number, it should add
whitespace correctly. It doesn't make sense to count tabs
as one space, and I'd say it violates the Principle of Least
Astonishment. In other words, a bug. :)

Changing the current behaviour to counting tabs as 8
(hard-coded) would at least be an improvement. Making it
configurable would be the extra feature.

BR,
Ulf W
-- 
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com
---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-bugs mailing list