Jump to page: 1 2
Thread overview
Solution for Fatal flaw in D design which is holding back widespread adoption(tm)
Mar 31, 2010
Bane
Mar 31, 2010
Jesse Phillips
Mar 31, 2010
Bane
Mar 31, 2010
Nick Sabalausky
Mar 31, 2010
Nick Sabalausky
Mar 31, 2010
Bane
Mar 31, 2010
Walter Bright
Mar 31, 2010
Nick Sabalausky
Mar 31, 2010
Jussi Jumppanen
Mar 31, 2010
Jérôme M. Berger
Mar 31, 2010
Bane
Mar 31, 2010
Walter Bright
Mar 31, 2010
Nick Sabalausky
Mar 31, 2010
Bane
Apr 01, 2010
Phil Deets
Apr 01, 2010
Phil Deets
Mar 31, 2010
Jérôme M. Berger
Re: Solution for Fatal flaw in D design which is holding back widespread
Mar 31, 2010
bearophile
March 31, 2010
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.

March 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
March 31, 2010
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.

March 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.


March 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...
>> 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.


March 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.
> 

March 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.
March 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.
> 
	Uncrustify already claims to support D:
http://uncrustify.sourceforge.net/

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr



March 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];
}
March 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.
« First   ‹ Prev
1 2