www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Solution for Fatal flaw in D design which is holding back widespread adoption(tm)

reply Bane <branimir.milosavljevic gmail.com> writes:
Would something like tidyMyHorribleDcode be a solution?
Put a conf file in source somewhere which states how many tabs/spaces/whatever. 
Before you comit code back to shared repository you run tidy to convert code to
D spe format.

When you checkout code from repo you run tidy with your custom settings.

A great & simple solution for trivial problem not worth talking about it.
Mar 31 2010
next sibling parent reply Jesse Phillips <jessekphillips+D gmail.com> writes:
Bane wrote:

 Would something like tidyMyHorribleDcode be a solution?
 Put a conf file in source somewhere which states how many
tabs/spaces/whatever. 
 Before you comit code back to shared repository you run tidy to convert code
to D spe format.

 When you checkout code from repo you run tidy with your custom settings.

 A great & simple solution for trivial problem not worth talking about it.
So, something like indent or bcpp for Linux? http://indent.isidore-it.eu/beautify.html http://www.faqs.org/docs/Linux-HOWTO/C-C++Beautifier-HOWTO.html
Mar 31 2010
parent Bane <branimir.milosavljevic gmail.com> writes:
Jesse Phillips Wrote:

 Bane wrote:
 
 Would something like tidyMyHorribleDcode be a solution?
 Put a conf file in source somewhere which states how many
tabs/spaces/whatever. 
 Before you comit code back to shared repository you run tidy to convert code
to D spe format.

 When you checkout code from repo you run tidy with your custom settings.

 A great & simple solution for trivial problem not worth talking about it.
So, something like indent or bcpp for Linux? http://indent.isidore-it.eu/beautify.html http://www.faqs.org/docs/Linux-HOWTO/C-C++Beautifier-HOWTO.html
Nah, they are unworthy. Not written in D.
Mar 31 2010
prev sibling next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Bane" <branimir.milosavljevic gmail.com> wrote in message 
news:hovb6n$13sr$1 digitalmars.com...
 Would something like tidyMyHorribleDcode be a solution?
 Put a conf file in source somewhere which states how many 
 tabs/spaces/whatever.
 Before you comit code back to shared repository you run tidy to convert 
 code to D spe format.

 When you checkout code from repo you run tidy with your custom settings.

 A great & simple solution for trivial problem not worth talking about it.
It would be a start. Used by itself it would be a bit of a hassle, but having it hooked up to auto-run upon checkout/commit or upon save/load in the editor (this would ideally be better since you can double-check the reults before committing) would be pretty much what I already had in mind as a solution. Alhough it wouldn't necessarily even need to be a full-fledged source formatter. Just something to sanitize the whitespace between start-of-line and anything non-whitespace would be a huge improvement *and* be cross-language.
Mar 31 2010
next sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:hp022i$t1h$1 digitalmars.com...
 "Bane" <branimir.milosavljevic gmail.com> wrote in message 
 news:hovb6n$13sr$1 digitalmars.com...
 Would something like tidyMyHorribleDcode be a solution?
 Put a conf file in source somewhere which states how many 
 tabs/spaces/whatever.
 Before you comit code back to shared repository you run tidy to convert 
 code to D spe format.

 When you checkout code from repo you run tidy with your custom settings.

 A great & simple solution for trivial problem not worth talking about it.
It would be a start. Used by itself it would be a bit of a hassle, but having it hooked up to auto-run upon checkout/commit or upon save/load in the editor (this would ideally be better since you can double-check the reults before committing) would be pretty much what I already had in mind as a solution. Alhough it wouldn't necessarily even need to be a full-fledged source formatter. Just something to sanitize the whitespace between start-of-line and anything non-whitespace would be a huge improvement *and* be cross-language.
And here's an even crazier idea: Some sort of well-thought-out UCF format (Unicode Code Format) that is like plain-text, but includes a standard metadata header (typically hidden while editing) that can help sort all this stuff out, and maybe other things as well. Obviously it would require special support from compilers and editors, but if it was well-designed (including discouragement of proprietary extensions - don't want a repeat of HTML) then I think it would be worth trying to push.
Mar 31 2010
next sibling parent Bane <branimir.milosavljevic gmail.com> writes:
 And here's an even crazier idea: Some sort of well-thought-out UCF format 
 (Unicode Code Format) that is like plain-text, but includes a standard 
 metadata header (typically hidden while editing) that can help sort all this 
 stuff out, and maybe other things as well. Obviously it would require 
 special support from compilers and editors, but if it was well-designed 
 (including discouragement of proprietary extensions - don't want a repeat of 
 HTML) then I think it would be worth trying to push.
Sounds complicated and error prone. I still have problems with notepad and his habit of killing utf-8 files and inserting bunch of ???? where all the nice chars were. Makes me want to kill somebody.
Mar 31 2010
prev sibling next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Nick Sabalausky wrote:
 And here's an even crazier idea: Some sort of well-thought-out UCF format 
 (Unicode Code Format) that is like plain-text, but includes a standard 
 metadata header (typically hidden while editing) that can help sort all this 
 stuff out, and maybe other things as well. Obviously it would require 
 special support from compilers and editors, but if it was well-designed 
 (including discouragement of proprietary extensions - don't want a repeat of 
 HTML) then I think it would be worth trying to push.
Sorry, but anything that requires D users to use a custom editor for a special source code file format is doomed to failure.
Mar 31 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:hp08a9$19la$2 digitalmars.com...
 Nick Sabalausky wrote:
 And here's an even crazier idea: Some sort of well-thought-out UCF format 
 (Unicode Code Format) that is like plain-text, but includes a standard 
 metadata header (typically hidden while editing) that can help sort all 
 this stuff out, and maybe other things as well. Obviously it would 
 require special support from compilers and editors, but if it was 
 well-designed (including discouragement of proprietary extensions - don't 
 want a repeat of HTML) then I think it would be worth trying to push.
Sorry, but anything that requires D users to use a custom editor for a special source code file format is doomed to failure.
I was thinking of it as whole-programming-world kind of thing not specific to any langauge, kind of like how UTF has been replacing ASCII and code pages (although this would use UTF). Basically kind of like a programmer's RTF (although it obviously wouldn't involve setting fonts and colors, but rather things like tab settings). I agree that getting it to actually happen would be an uphill battle (especially if there's no large organization backing it :( ), but it could be worth the potential benefits if it were to happen.
Mar 31 2010
parent Jussi Jumppanen <jussij zeusedit.com> writes:
Nick Sabalausky Wrote:

 I was thinking of it as whole-programming-world kind of thing not specific 
 to any langauge, kind of like how UTF has been replacing ASCII and code 
 pages (although this would use UTF). Basically kind of like a programmer's 
 RTF (although it obviously wouldn't involve setting fonts and colors, but 
 rather things like tab settings).
You mean something like PTSC - http://www.synchro.net/ptsc_hdr.html
Mar 31 2010
prev sibling parent =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Nick Sabalausky wrote:
 And here's an even crazier idea: Some sort of well-thought-out UCF form=
at=20
 (Unicode Code Format) that is like plain-text, but includes a standard =
 metadata header (typically hidden while editing) that can help sort all=
this=20
 stuff out, and maybe other things as well. Obviously it would require=20
 special support from compilers and editors, but if it was well-designed=
=20
 (including discouragement of proprietary extensions - don't want a repe=
at of=20
 HTML) then I think it would be worth trying to push.
=20
You mean like the Emacs/vim headers which allow to specify everything in special comments near the top or bottom of the file and Emacs/vim sets the appropriate options automatically upon loading the file? http://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.h= tml Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Mar 31 2010
prev sibling next sibling parent Bane <branimir.milosavljevic gmail.com> writes:
 It would be a start. Used by itself it would be a bit of a hassle, but 
 having it hooked up to auto-run upon checkout/commit or upon save/load in 
 the editor (this would ideally be better since you can double-check the 
 reults before committing) would be pretty much what I already had in mind as 
 a solution.
My thinking the same.
 
 Alhough it wouldn't necessarily even need to be a full-fledged source 
 formatter. Just something to sanitize the whitespace between start-of-line 
 and anything non-whitespace would be a huge improvement *and* be 
 cross-language. 
 
Only thing to be taken into special consideration are multi line strings. Sanitizing them would produce errors. Some kind of lexer or advanced regexpr match might be required.
 
Mar 31 2010
prev sibling next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Nick Sabalausky wrote:
 Alhough it wouldn't necessarily even need to be a full-fledged source 
 formatter. Just something to sanitize the whitespace between start-of-line 
 and anything non-whitespace would be a huge improvement *and* be 
 cross-language. 
I think that's a great idea. Yesterday, I wrote the following program and added it to the dmd makefile so that all checkins and installs run the source code through it first. I welcome improvements. The current version replaces tabs with spaces, and removes trailing whitespace. If someone is ambitious, a full fletched D source code pretty printer would be valuable that anyone could use, and which all Phobos source code could be run through in order to enforce a common style. ---------------------------------------- /* Replace tabs with spaces, and remove trailing whitespace from lines. */ import std.file; import std.path; int main(string[] args) { foreach (f; args[1 .. $]) { auto input = cast(char[]) std.file.read(f); auto output = filter(input); if (output != input) std.file.write(f, output); } return 0; } char[] filter(char[] input) { char[] output; size_t j; int column; for (size_t i = 0; i < input.length; i++) { auto c = input[i]; switch (c) { case '\t': while ((column & 7) != 7) { output ~= ' '; j++; column++; } c = ' '; column++; break; case '\r': case '\n': while (j && output[j - 1] == ' ') j--; output = output[0 .. j]; column = 0; break; default: column++; break; } output ~= c; j++; } while (j && output[j - 1] == ' ') j--; return output[0 .. j]; }
Mar 31 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound1 digitalmars.com> wrote in message 
news:hp087r$19la$1 digitalmars.com...
 Nick Sabalausky wrote:
 Alhough it wouldn't necessarily even need to be a full-fledged source 
 formatter. Just something to sanitize the whitespace between 
 start-of-line and anything non-whitespace would be a huge improvement 
 *and* be cross-language.
I think that's a great idea. Yesterday, I wrote the following program and added it to the dmd makefile so that all checkins and installs run the source code through it first. I welcome improvements. The current version replaces tabs with spaces, and removes trailing whitespace.
Sounds great.
 If someone is ambitious, a full fletched D source code pretty printer 
 would be valuable that anyone could use, and which all Phobos source code 
 could be run through in order to enforce a common style.
For bonus points, they could expose it as a library so editors and other tools can make use of it without shuffling everything through command-line params, stdout and the filesystem.
Mar 31 2010
parent Bane <branimir.milosavljevic gmail.com> writes:
Nick Sabalausky Wrote:

 "Walter Bright" <newshound1 digitalmars.com> wrote in message 
 news:hp087r$19la$1 digitalmars.com...
 Nick Sabalausky wrote:
 Alhough it wouldn't necessarily even need to be a full-fledged source 
 formatter. Just something to sanitize the whitespace between 
 start-of-line and anything non-whitespace would be a huge improvement 
 *and* be cross-language.
I think that's a great idea. Yesterday, I wrote the following program and added it to the dmd makefile so that all checkins and installs run the source code through it first. I welcome improvements. The current version replaces tabs with spaces, and removes trailing whitespace.
Sounds great.
 If someone is ambitious, a full fletched D source code pretty printer 
 would be valuable that anyone could use, and which all Phobos source code 
 could be run through in order to enforce a common style.
For bonus points, they could expose it as a library so editors and other tools can make use of it without shuffling everything through command-line params, stdout and the filesystem.
Will it work with multiline strings? char[] s = r""" I am very wide string""";
Mar 31 2010
prev sibling parent reply "Phil Deets" <pjdeets2 gmail.com> writes:
On Wed, 31 Mar 2010 11:49:31 -0600, Nick Sabalausky <a a.a> wrote:

 Alhough it wouldn't necessarily even need to be a full-fledged source
 formatter. Just something to sanitize the whitespace between  
 start-of-line
 and anything non-whitespace would be a huge improvement *and* be
 cross-language.
Crimson Editor (my preferred D text editor) has menu options to convert tabs to spaces, convert leading tabs to spaces, convert spaces to tabs, and remove trailing spaces.
Mar 31 2010
parent "Phil Deets" <pjdeets2 gmail.com> writes:
On Wed, 31 Mar 2010 21:10:22 -0600, Phil Deets <pjdeets2 gmail.com> wrote:

 On Wed, 31 Mar 2010 11:49:31 -0600, Nick Sabalausky <a a.a> wrote:

 Alhough it wouldn't necessarily even need to be a full-fledged source
 formatter. Just something to sanitize the whitespace between  
 start-of-line
 and anything non-whitespace would be a huge improvement *and* be
 cross-language.
Crimson Editor (my preferred D text editor) has menu options to convert tabs to spaces, convert leading tabs to spaces, convert spaces to tabs, and remove trailing spaces.
Correction: It has leading spaces to tabs, not leading tabs to spaces.
Mar 31 2010
prev sibling parent reply =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= <jeberger free.fr> writes:
Bane wrote:
 Would something like tidyMyHorribleDcode be a solution?
 Put a conf file in source somewhere which states how many tabs/spaces/w=
hatever.=20
 Before you comit code back to shared repository you run tidy to convert=
code to D spe format.
=20
 When you checkout code from repo you run tidy with your custom settings=
=2E
=20
 A great & simple solution for trivial problem not worth talking about i=
t.
=20
Uncrustify already claims to support D: http://uncrustify.sourceforge.net/ Jerome --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Mar 31 2010
parent bearophile <bearophileHUGS lycos.com> writes:
Jérôme M. Berger:
 	Uncrustify already claims to support D:
 http://uncrustify.sourceforge.net/
I have tried that "Universal Indent GUI" with Uncrustify. It seems nice but it has so many options that finding the correct ones is lot of work, even if you use that GUI: http://uncrustify.sourceforge.net/config.txt It seems unable to recognize foreach and foreach_reverse. Bye, bearophile
Mar 31 2010