List:Internals« Previous MessageNext Message »
From:Michael Izioumtchenko Date:March 5 2009 8:46pm
Subject:Re: MySQL University Session: Good Coding Style follow up
View as plain text  

shlomo.swidler@stripped wrote:
> It doesn't sound too hard to take any language that adheres to a
> grammar (C, Java, etc.) and write a program that transforms any input
> adhering to that grammar into a custom defined coding style, according
> to a pluggable template. It sounds so obvious - does anyone know of
> any such thing?
>
> Such a utility could be used to solve the "diff against an old file -
> dangit, it's in a different coding style" problem: just run the old
> code through the tool to transform it, then diff.
>
>   
I'm not sure if it's as easy as it sounds. One thing is that C 
preprocessor is distinct from the compiler
and the styling for #define is usually different from the code, as in

#define FOO do {foo} while (0);

which would be laughed at when used outside #define.
Grammars seem to have hard time defining things like line numbers, 
comment style, placement on page,
TABs vs blanks so 'a C program conforming to a style' would be a much 
bigger grammar than just a C program,
if at all existing.
Overall it the transformation approach sounds like half the compiler. In 
fact anything could be done within the compiler,
someone just needs to  advocate it with gcc developers. They have so 
many optimization and warning flags, why not
add something for if (foo) bar; vs. if (foo) {bar} vs.

if (foo)
{
      bar;
}

Thanks,
Michael  Izioumtchenko
Thread
MySQL University Session: Good Coding Style follow upKonstantin Osipov5 Mar
  • Re: MySQL University Session: Good Coding Style follow upRoy Lyseng5 Mar
    • Re: MySQL University Session: Good Coding Style follow upKonstantin Osipov5 Mar
      • Re: MySQL University Session: Good Coding Style follow upMichael Widenius8 Mar
    • Re: MySQL University Session: Good Coding Style follow upMichael Widenius8 Mar
      • Re: MySQL University Session: Good Coding Style follow upRoy Lyseng8 Mar
        • Re: MySQL University Session: Good Coding Style follow upMichael Widenius9 Mar
          • Re: MySQL University Session: Good Coding Style follow upJay Pipes9 Mar
            • Re: MySQL University Session: Good Coding Style follow upMichael Widenius11 Mar
              • Re: MySQL University Session: Good Coding Style follow upJay Pipes11 Mar
                • Re: MySQL University Session: Good Coding Style follow upMichael Widenius18 Mar
      • Re: MySQL University Session: Good Coding Style follow upStewart Smith17 Mar
  • Re: MySQL University Session: Good Coding Style follow upMARK CALLAGHAN5 Mar
    • Re: MySQL University Session: Good Coding Style follow upIngo Strüwing5 Mar
      • Re: MySQL University Session: Good Coding Style follow upMARK CALLAGHAN5 Mar
        • Re: MySQL University Session: Good Coding Style follow upIngo Strüwing5 Mar
          • Re: MySQL University Session: Good Coding Style follow upMARK CALLAGHAN5 Mar
            • Re: MySQL University Session: Good Coding Style follow upJay Pipes5 Mar
              • Re: MySQL University Session: Good Coding Style follow upMichael Widenius8 Mar
                • Re: MySQL University Session: Good Coding Style follow upJay Pipes8 Mar
            • Re: MySQL University Session: Good Coding Style follow upKonstantin Osipov5 Mar
              • Re: MySQL University Session: Good Coding Style follow upMARK CALLAGHAN5 Mar
              • Re: MySQL University Session: Good Coding Style follow upMichael Widenius8 Mar
    • Re: MySQL University Session: Good Coding Style follow upSergey Petrunia5 Mar
  • Re: MySQL University Session: Good Coding Style follow upDavi Arnaut5 Mar
    • Re: MySQL University Session: Good Coding Style follow upKonstantin Osipov5 Mar
      • Re: MySQL University Session: Good Coding Style follow upDavi Arnaut5 Mar
  • Re: MySQL University Session: Good Coding Style follow upJonas Oreland5 Mar
    • Re: MySQL University Session: Good Coding Style follow upKonstantin Osipov5 Mar
      • Re: MySQL University Session: Good Coding Style follow upJonas Oreland5 Mar
        • Re: MySQL University Session: Good Coding Style follow upshlomo.swidler5 Mar
          • Re: MySQL University Session: Good Coding Style follow upMichael Izioumtchenko5 Mar
        • Re: MySQL University Session: Good Coding Style follow upMichael Izioumtchenko5 Mar
        • Re: MySQL University Session: Good Coding Style follow upStewart Smith17 Mar
      • Re: MySQL University Session: Good Coding Style follow upMichael Widenius8 Mar
Re: MySQL University Session: Good Coding Style follow upKonstantin Osipov5 Mar
  • Re: MySQL University Session: Good Coding Style follow upMARK CALLAGHAN5 Mar
  • Re: MySQL University Session: Good Coding Style follow upMichael Widenius6 Mar
    • Re: MySQL University Session: Good Coding Style follow upKonstantin Osipov6 Mar
      • Re: MySQL University Session: Good Coding Style follow upMARK CALLAGHAN6 Mar
      • Re: MySQL University Session: Good Coding Style follow upMichael Widenius8 Mar