> Indentation's purpose is to show scope, I'm uncertain if alignment even makes
> more readable code.
No, indentation is certainly not a way to indicate scoping as in old languages,
such as Pascal, an IF, a FOR or a WHILE statement doesn’t create a new scope.
Even in Python an if, a for or a wh
> @Araq: You have to use gofmt to get it or you need to be conciously aware of
> tabs vs spaces all the time. Excuse me, but I prefer to spend more time on
> the algorithmic aspects of my code.
Modern editors are surprisingly good at keeping this complexity away from you.
VS-code with Golang ex
> Of course a good editor could fix that...
Well I'm not gonna change the language for people who prefer to use broken
tools, sorry.
But there is a good alternative: Let's focus our efforts on a standard tree
format for programming languages. We can then store code as trees on the disk
and eve
> Nim's hard choice of "two spaces per indent" is not helping its adoption. It
> might seem as a pet peeve but for new Nim users with experience in other
> languages it can be a serious irritation.
There is no such "hard choice" and there is no evidence whatsoever that it
hinders its adoption.
I tried using proportional fonts for programming once. Very awkward. You are
more adventurous than most. [Barely relevant, but
funny.](https://forum.nim-lang.org/t/6891#43159).
It's the other way round: Space key refers to the space, the empty room between
two things, like two words. Tabs may be not the ideal solution for indentation,
as tabs have not been really invented for it. But indentation by those tiny
spaces will ever feel wrong. For people like me using a prop
I feel like one very important point people miss when saying tabs should be
used for indentation is the fact that tabs actually have a different purpose.
It's in the name: _Tabulator_. Not indentator.
Well I never said it was useless, I just don't get the point. Indentation's
purpose is to show scope, I'm uncertain if alignment even makes more readable
code. Do want to say though that you can omit the `()` and just write as
follows not that I suggest this.
if
10 == 10 or
We want alignment for instance in this case:
if some_long_expression and
another_long_expression and
another_one:
Run
Of course, we could use parentheses and write, using only indentation:
if (
some_long_expression and
another_lon
Why is it always people say "Tabs for indenting and spaces for alignment",
since when was alignment a requirement of code. "Tabs for indenting and spaces
for spaces" is where it's at. I do not see any benefit of aligning code using
spaces, if you want to have aligned code you can always do the b
> @Stefan_Salewski: Python does or at least did allow Tabs for indentation, so
> it is possible.
Python 2 allowed Tabs and Spaces and their mixing. Python 3 allows Tabs and
Spaces but does not allow mixing them in indentation.
> Popularity and wide spread of Golang
We should really not compare to Golang.
Golang has not significant white space, and Golang's main reason for its
popularity is that it is a child of Google.
The initial fear in Nim about tabs was that mixing tabs and spaces for
indentation would be very b
> @Araq: Oh not that again... That never worked for any codebase I've ever seen.
Popularity and wide spread of Golang is a testament that "TABs for indentation,
Spaces for alignment" does work in practice. In fact, editors like VScode and
Goland achieve it so transparently that many Golang coder
Some more details here to support @Araq's point and
[links](https://forum.nim-lang.org/t/2105) to [prior
discussion](https://forum.nim-lang.org/t/5943). This really does seem like an
editor question, though. The only reason this style might be attractive in the
first place is because most edito
> We have really discussed that topic enough in the last 5 years.
Yeah, I'm waiting for 5 years for an answer why your editor cannot turn tabs
into spaces.
> Use an editor that replaces tabs with whitespace.
We have really discussed that topic enough in the last 5 years.
For your point: Our intention is not to make the TAB key work. We regard tabs
as the native, flexible entity for indentation, we would like that tabs survive
in the code base. And
Use an editor that replaces tabs with whitespace.
> Oh not that again... That never worked for any codebase I've ever seen.
That's what people said about significant whitespace until Python and a few
others proved that its works fine.
> constant friction when editing code ("oh no, I pressed a space, must undo and
> use a tab")
For me it is th
> TABs for indentation, spaces for alignment.
Oh not that again... That never worked for any codebase I've ever seen.
Compressing 8 spaces with a tab was a common setting for emacs (iirc?) so in
practice I was stuck for good with tab = 8 spaces.
But even if it would work, it would be a constant
> @HJarausch: Oh well, I have coded more than a million lines of code in more
> than a dozens of programming languages. I have been teaching Pascal/C++ for
> more than 3 decades at a university. ... So one develops one's own style.
I cannot brag of writing 1M LOCs :-) but been professionally pro
That was one of the reasons they have replaced their parser by a recursive
descend parser.
For quite a long while C++ required space between closing `>` in nested
templates like this `Foo >`. Compact version `Foo>` was not
standards compliant because `>>` is right-shift operator.
Given that `echo(1, 2)` and `echo (1, 2)` are two completely different things
in Nim (and yet quite intuitive IMHO) these warnings -- if doable at all --
would only be annoying. Tools cannot replace understanding.
Oh well, I have coded more than a million lines of code in more than a dozens
of programming languages. I have been teaching Pascal/C++ for more than 3
decades at a university.
So one develops one's own style. And it's just a matter of style. I can
remember only very few places where white spac
Well,ifyo ulik etodro pwhi tespac esatra ndom,Ni mwo n'tbeyo urfri end... Like
in many languages!;-)
As I learned from my own trials and errors, Nim is a white-space-sensitive
language that likes white space consistency. After a bit of practice I do not
feel that limits me in any way.
Thanks, an embarrassing error, but why didn't this get flagged? Now the line
var ChkPoints= initTable[int, (HashSet[T2int], DigSet, int)] ()
Run
gives Error: type mismatch: got but expected one of: proc
(initialSize: int): Table[system.int, (HashSet[BUG.T2int], DigSe
Remove the space between `]` and `(`: `initTable[int, (HashSet[T2int], DigSet,
int)]()`
But this will continue to bite you in the future because of your sloppy writing
style when it comes to whitespace: you have it in places where you shouldn't,
you don't have it where it would be nice to have,
It turns out that Nim has problems with the blank before () in
var ChkPoints= initTable[int, (HashSet[T2int], DigSet, int)] ()
^
Run
That's a pity and hard to find.
Don't `include` modules. `import` them.
include tables, sets
type
BS8 = set[int8]
DigSet = array[9,BS8]
T2int = tuple[f:int8,s:int8]
var
FreeCell:HashSet[T2int]
Row_Digits : DigSet
R_Cells : int
var ChkPoints= initTable[int, (HashSet[T2int], DigSet, int)] ()
31 matches
Mail list logo