Re: Tabulation symbols not allowed

2016-09-10 Thread LeuGim
To my previous post: that would break visual code alignment if tabs are used 
for such alignment inside lines of code, not at beginning; tabs should be 
replaced there by variable number of spaces. Yet someone can use literal tabs 
inside strings (though mostly escape sequences are used), so the filter should 
avoid them. So a separate filter is needed.


Re: Tabulation symbols not allowed

2016-09-09 Thread LeuGim
But it works already with `#? replace(sub="\t",by=" ")`. 


Re: Tabulation symbols not allowed

2016-09-08 Thread Araq
For existing libraries you can transform the input on load and transform it 
back on save. Not particularly elegant, but gives you lots of freedom and also 
solves other issues (like stripping trailing whitespace).


Re: Tabulation symbols not allowed

2016-09-08 Thread OderWat
Allowing tabs means "allowing mixed" because TABs are what the are. They are 
not "4 spaces in the package of one `\t`" they are meant as stops at fixed 
positions starting from 0 and if you use a Tabstop of 4 and you use indentation 
of 2 you will have 1 tab and two spaces in front of your text at indent level 3.

Allowing `\t` to let uses choose how their indentation width is, makes probably 
sense if you only allow tabs and no spaces but not if you allow both (mixed or 
not).

So if you really want to allow tabs the Nim compiler needs to know the tab 
width intended to be used. This would complicate the parser I guess but would 
be possible as preprocessor which converts the given tab size to spaces before 
continuing with compilation. That would be even transparent imho (as for 
example the columns position would stay the same for error reporting).

To me this boils down that there could be a source-code-filter which gets a 
tab-size and does the correct tab transformation on the source. This way 
everybody who wants can use tabs in his sources and Nim itself does not need to 
change anything besides the inclusion of such filter.

I guess a PR would maybe go through :)


Re: Tabulation symbols not allowed

2016-09-08 Thread Stefan_Salewski
Yes, for your example you are right. I have never done such type of alignment 
myself in my code, but indeed there seems to exist people who like that. Indeed 
for that type of alignment proportional fonts do not work. Really a nice 
example.

> Indent width can always be freely rendered

Yes, with your NimEdit :)

For closed source editors that may be possible or not. And for Open Source 
code, we may have to patch the code for our personal use. For example for 
GtkSourceView all developers seems to be retired, so there is currently no 
chance for extensions -- I do not think that my own patched would be accepted. 
(I recently asked GTK people about indent marks as you have in your NimEdit, or 
about smart line wrapping. No reaction unfortunately.) 


Re: Tabulation symbols not allowed

2016-09-08 Thread Araq
> And no one wants to allow mixing.

Mixing always happens (and is in fact what you're arguing for):


proc outer =
  # indentation:
  proc foo(x, y: string,
   z: int) = # ind+alignment of 'z' to be on the same column as '('
# indentation again


> There is one big advantage of tabs: Indent width can be freely configured, 
> without the need to modify the source code itself.

Indent width can always be freely _rendered_ because that's what text editors 
do, they render a stream of bytes. Byte 9 has no inherent advantage over a 
series of byte 32. The only advantage arises when you use clearly distinguish 
between indentation and alignment and use different bytes for these. Which is 
not user friendly because it means you make the human being perform this 
distinction all the time so that your computer program can remain simple. 


Re: Tabulation symbols not allowed

2016-09-08 Thread Stefan_Salewski
> The big problem I've had with tabs was in team programming,

But there is no problem, as long as tabs and spaces are not mixed for 
indentation purpose in a single file. And no one wants to allow mixing.

There is one big advantage of tabs: Indent width can be freely configured, 
without the need to modify the source code itself.

And spaces can be very tiny for some proportional fonts, so that the default 2 
spaces per indent step are too small, so I use 3 or four spaces per step, which 
is again large for people with other fonts.

Forbidding tabs is a very strong restriction for our freedom. But there is one 
reason why I am currently willing to accept it -- github makes tabs equal to 8 
spaces, so for github hosted files I would have to replace my tabs to spaces 
anyway.


Re: Tabulation symbols not allowed

2016-09-08 Thread bogen
> But forbidding tabs I don't like.

You stated you use gedit, which handles indentation (via the tab key) with 
either spaces or tabs, and that is very simple to configure.

Most decent editors have this feature. For me I prefer Nim not allowing tabs. I 
don't see the point of having tabs used for indentation in the source code when 
just about every editor out there can be configured to indent with spaces via 
the tab key.

The big problem I've had with tabs was in team programming, where some 
preferred tabs, and other's spaces (via the tab key). It was a big mess. We 
ended up just banning tabs all together and agreeing on how many indent spaces 
would be used.

Anyways, "tabs vs spaces" is one of those continual ongoing computer holy wars 
for well over 15 years. Just do a web search on it. I've been programming for 
over 30 years. In my opinion tabs not being allowed in Nim source code is a 
very good thing. They are totally unnecessary and have no real added value (in 
my opinion). Tab characters can appear in strings in nim, just not for 
indentation.

> When i write code in text editor, the indentation with two spaces is little 
> noticeable, the indentation with more spaces is more noticeable, but if i 
> need 3 or more levels of indentation, writing 12 spaces takes too much time.

That makes no sense. Just configure your tab key to indent with spaces, not tab 
characters. 


Re: Tabulation symbols not allowed

2016-09-05 Thread vlad1777d
> With proportional fonts unfortunately 2 spaces generate a tiny indent step. 
> So I have to use 3 or 4 spaces, or finally a tab! I think I will do the later 
> with the replace command mentioned above. The only disadvantage is that 
> github puts 8 spaces for each tab, so I have to convert files before 
> uploading to github.

I use fixed width fonts only for convenience of reading (and then, because they 
were installed by default) (I use default fonts because this is not important 
for me). You can use any, which you want.

But forbidding tabs I don't like. It's bad idea, as I think. It's not difficult 
to allow them in the source code of Nim's compiler. Compilerlanguage is 
instrument for every humangroup of people, so, as I think, everybody can choose 
one, which is most convenient for himthem.