digitalmars.D - Solution for Fatal flaw in D design which is holding back widespread adoption(tm)
- Bane (5/5) Mar 31 2010 Would something like tidyMyHorribleDcode be a solution?
- Jesse Phillips (4/9) Mar 31 2010 So, something like indent or bcpp for Linux?
- Bane (2/17) Mar 31 2010 Nah, they are unworthy. Not written in D.
- Nick Sabalausky (11/18) Mar 31 2010 It would be a start. Used by itself it would be a bit of a hassle, but
- Nick Sabalausky (9/30) Mar 31 2010 And here's an even crazier idea: Some sort of well-thought-out UCF forma...
- Bane (1/8) Mar 31 2010 Sounds complicated and error prone. I still have problems with notepad a...
- Walter Bright (3/10) Mar 31 2010 Sorry, but anything that requires D users to use a custom editor for a s...
- Nick Sabalausky (10/20) Mar 31 2010 I was thinking of it as whole-programming-world kind of thing not specif...
- Jussi Jumppanen (2/7) Mar 31 2010 You mean something like PTSC - http://www.synchro.net/ptsc_hdr.html
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (16/24) Mar 31 2010 this=20
- Bane (2/14) Mar 31 2010
- Walter Bright (61/65) Mar 31 2010 I think that's a great idea. Yesterday, I wrote the following program an...
- Nick Sabalausky (6/18) Mar 31 2010 Sounds great.
- Bane (5/30) Mar 31 2010 Will it work with multiline strings?
- Phil Deets (4/9) Mar 31 2010 Crimson Editor (my preferred D text editor) has menu options to convert ...
- Phil Deets (2/13) Mar 31 2010 Correction: It has leading spaces to tabs, not leading tabs to spaces.
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (12/20) Mar 31 2010 code to D spe format.
- bearophile (6/8) Mar 31 2010 I have tried that "Universal Indent GUI" with Uncrustify. It seems nice ...
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
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
Jesse Phillips Wrote:Bane wrote:Nah, they are unworthy. Not written in D.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
"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
"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...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.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
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
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
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:hp08a9$19la$2 digitalmars.com...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). 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.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
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
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=20stuff 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=20HTML) then I think it would be worth trying to push. =20You 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
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
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
"Walter Bright" <newshound1 digitalmars.com> wrote in message news:hp087r$19la$1 digitalmars.com...Nick Sabalausky wrote:Sounds great.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.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
Nick Sabalausky Wrote:"Walter Bright" <newshound1 digitalmars.com> wrote in message news:hp087r$19la$1 digitalmars.com...Will it work with multiline strings? char[] s = r""" I am very wide string""";Nick Sabalausky wrote:Sounds great.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.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
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
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:Correction: It has leading spaces to tabs, not leading tabs to spaces.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
Bane wrote:Would something like tidyMyHorribleDcode be a solution? Put a conf file in source somewhere which states how many tabs/spaces/w=hatever.=20Before 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.=20Uncrustify 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
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