January 29, 2012
Hello!

It was mentioned in #D that gdc will probably adapt its code to GNU code style and I wonder, seeing no recemmendation in http://www.d-programming-language.org/dstyle.html in regard to indent-style, can someone shed some light what is recommended practice for it within D community?


Sincerely,
Gour

-- 
What is night for all beings is the time of awakening for the self-controlled; and the time of awakening for all beings is night for the introspective sage.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


January 29, 2012
On 29-01-2012 10:15, Gour wrote:
> Hello!
>
> It was mentioned in #D that gdc will probably adapt its code to GNU code
> style and I wonder, seeing no recemmendation in
> http://www.d-programming-language.org/dstyle.html in regard to
> indent-style, can someone shed some light what is recommended practice
> for it within D community?
>
>
> Sincerely,
> Gour
>

Phobos generally uses 4-space indentation.

-- 
- Alex
January 29, 2012
On Sun, 29 Jan 2012 12:21:35 +0100
Alex Rønne Petersen <xtzgzorex@gmail.com> wrote:

> Phobos generally uses 4-space indentation.

That is mentioned in the style-guide, but I'm curious about bracing, iow, GNUstyle, K&R, ANSI...?


Sincerely,
Gour


-- 
The working senses are superior to dull matter; mind is higher than the senses; intelligence is still higher than the mind; and he [the soul] is even higher than the intelligence.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


January 29, 2012
> http://www.d-programming-language.org/dstyle.html in regard to
> indent-style, can someone shed some light what is recommended practice
> for it within D community?

Everyone thinks his way is the best.
January 29, 2012
Am 29.01.2012, 12:34 Uhr, schrieb Gour <gour@atmarama.net>:

> On Sun, 29 Jan 2012 12:21:35 +0100
> Alex Rønne Petersen <xtzgzorex@gmail.com> wrote:
>
>> Phobos generally uses 4-space indentation.
>
> That is mentioned in the style-guide, but I'm curious about bracing,
> iow, GNUstyle, K&R, ANSI...?

Some people seem to use that godawful BSD KNF style.
But I've also seen lots of Allman (ANSI)-style code.
January 29, 2012
On Sunday, January 29, 2012 12:34:22 Gour wrote:
> On Sun, 29 Jan 2012 12:21:35 +0100
> 
> Alex Rønne Petersen <xtzgzorex@gmail.com> wrote:
> > Phobos generally uses 4-space indentation.
> 
> That is mentioned in the style-guide, but I'm curious about bracing, iow, GNUstyle, K&R, ANSI...?

Phobos uses Allman: http://en.wikipedia.org/wiki/Indent_style#Allman_style

But everyone is free to format their code how they like. Personally, I've never understood how anyone can stand anything other than Allman, but to each their own, I suppose.

- Jonathan M Davis
January 29, 2012
29.01.2012 15:21, Alex Rønne Petersen пишет:
> On 29-01-2012 10:15, Gour wrote:
>> Hello!
>>
>> It was mentioned in #D that gdc will probably adapt its code to GNU code
>> style and I wonder, seeing no recemmendation in
>> http://www.d-programming-language.org/dstyle.html in regard to
>> indent-style, can someone shed some light what is recommended practice
>> for it within D community?
>>
>>
>> Sincerely,
>> Gour
>>
>
> Phobos generally uses 4-space indentation.
>

I don't think there is the best coding style (personally I like both K&R and Allman styles). IMHO things are different with indention. Why does Phobos use 4-space indentation?

The following article (IMHO) completely covers tabs vs spaces problem:
http://www.emacswiki.org/cgi-bin/wiki/TabsAreEvil

It shows that tabs (in spite of the article title) are really good and should be used always (and only) for indention. Looks like Allman style doesn't prevent this (if it does, what is the reason?). So:
* Such tab using shows respect to a programmer allowing him to configure tab size as he prefer.
* Sometimes indention should be changed for a particular using.
* Worst of all, sometimes same code is used in different places where different indention levels are expected.
* Using spaces guarantee that code will look same in every editor but it is the simplest and not the most convenient way, the code should look _good for every editor user_, not _same_, so it tears down our community.
* It's less comfortable to use spaces for indention in every editor I use (at least because spaces allows caret position in the middle of indention and pressing <one of delete one char keys> deletes one space instead of the indention level, so it's easy to accidentally broke indention and use, e.g. 7 instead of 8 spaces).

And this isn't only a theory. In practice:
* I've never liked 8-chars indention, so I feels myself bad in d-p-l.org sources. Probably I'm not the only one.
* I accidentally brake spaces indention sometimes. Probably I'm not the less-trained-in-printing one.
* Some time ago a ebook version of d-p-l.org has been created. Walter had to change every 4-spaces indention in examples to 2-spaces indention for convenience reading on small PPC screen.
* Now everyone see 2-spaces indented examples in d-p-l.org instead of his, probably, preferred 4-spaces indented.

Am I mistaken? If no, am I missing some major spaces advantages? If no, lets use tabs. Perhaps, there is no tool that will convert (convert right, not somehow, see article) tabs<->spaces in D code.
January 29, 2012
On 29 January 2012 14:04, Denis Shelomovskij <verylonglogin.reg@gmail.com> wrote:
> 29.01.2012 15:21, Alex Rønne Petersen пишет:
>
>> On 29-01-2012 10:15, Gour wrote:
>>>
>>> Hello!
>>>
>>> It was mentioned in #D that gdc will probably adapt its code to GNU code style and I wonder, seeing no recemmendation in http://www.d-programming-language.org/dstyle.html in regard to indent-style, can someone shed some light what is recommended practice for it within D community?
>>>
>>>
>>> Sincerely,
>>> Gour
>>>
>>
>> Phobos generally uses 4-space indentation.
>>
>
> I don't think there is the best coding style (personally I like both K&R and Allman styles). IMHO things are different with indention. Why does Phobos use 4-space indentation?
>
> The following article (IMHO) completely covers tabs vs spaces problem: http://www.emacswiki.org/cgi-bin/wiki/TabsAreEvil
>
> It shows that tabs (in spite of the article title) are really good and
> should be used always (and only) for indention. Looks like Allman style
> doesn't prevent this (if it does, what is the reason?). So:
> * Such tab using shows respect to a programmer allowing him to configure tab
> size as he prefer.
> * Sometimes indention should be changed for a particular using.
> * Worst of all, sometimes same code is used in different places where
> different indention levels are expected.
> * Using spaces guarantee that code will look same in every editor but it is
> the simplest and not the most convenient way, the code should look _good for
> every editor user_, not _same_, so it tears down our community.
> * It's less comfortable to use spaces for indention in every editor I use
> (at least because spaces allows caret position in the middle of indention
> and pressing <one of delete one char keys> deletes one space instead of the
> indention level, so it's easy to accidentally broke indention and use, e.g.
> 7 instead of 8 spaces).
>
> And this isn't only a theory. In practice:
> * I've never liked 8-chars indention, so I feels myself bad in d-p-l.org
> sources. Probably I'm not the only one.
> * I accidentally brake spaces indention sometimes. Probably I'm not the
> less-trained-in-printing one.
> * Some time ago a ebook version of d-p-l.org has been created. Walter had to
> change every 4-spaces indention in examples to 2-spaces indention for
> convenience reading on small PPC screen.
> * Now everyone see 2-spaces indented examples in d-p-l.org instead of his,
> probably, preferred 4-spaces indented.
>
> Am I mistaken? If no, am I missing some major spaces advantages? If no, lets use tabs. Perhaps, there is no tool that will convert (convert right, not somehow, see article) tabs<->spaces in D code.

The problem is lines with mixed tabs and spaces, and different users set their text editors see tabs differently. ie: is your tab-width set to 2, 3, 4, or 8?

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
January 29, 2012
Denis Shelomovskij:

> Am I mistaken? If no, am I missing some major spaces advantages? If no, lets use tabs.

D2 style guide should *require* D2 to be edited using a mono-spaced font, and the D2 front-end should enforce this with a "-ms" compiler switch.

Bye,
bearophile
January 29, 2012
http://media.comicvine.com/uploads/6/67698/1595201-oh_look_its_this_thread_again_super.jpg


« First   ‹ Prev
1 2 3 4 5 6 7 8 9
Top | Discussion index | About this forum | D home