Is D open for different code conventions?
eao197
eao197 at intervale.ru
Mon Jul 30 02:48:22 PDT 2007
I just want to ask D's community: it is appropriate if some projects will
use different code convention?
I used CamelCase code convention, which was very similar to the current
D's style, for more than 6 years, but with time I felt that my eyes got
tired when dealing with big amount of CamelCase formatted code. So I
switched to lower_case style and use it for last 6 years.
Now, when I try to write D code in CamelCase style I've found the same
problem again -- my eyes get tired quickly. Because in code like such:
void
parseLine( char[] line, bool showGoodMessages )
{
if( line.length <= 2 )
return;
auto binImage = tryExtractShortMessageBody( line );
if( binImage !is null )
{
auto analyzingResult = tryHandleHeadersAndBody( binImage );
if( analyzingResult.isGoodMessage() )
{
if( showGoodMessages )
Stdout.formatln( "OK: {0}", analyzingResult );
}
else
showBadMessage( line, analyzingResult );
}
else
Stderr.formatln( "nothing found in {0}", line );
}
it is hard to read indentifiers like tryHandleHeadersAndBody. So I prefer
to write:
void
parse_line( char[] line, bool show_good_messages )
{
if( line.length <= 2 )
return;
auto bin_image = try_extract_short_message_body( line );
if( bin_image !is null )
{
auto analyzing_result = try_handle_headers_and_body( bin_image );
if( analyzing_result.is_good_message() )
{
if( show_good_messages )
Stdout.formatln( "OK: {0}", analyzing_result );
}
else
show_bad_message( line, analyzing_result );
}
else
Stderr.formatln( "nothing found in {0}", line );
}
I think it would be good if there will be possibility to use different
code convention in D. For example, like Ruby's: CamelCase for class names
and lower_case for method names, or like C++ ACE's: Camel_Case for classes
and lower_case for methods.
--
Regards,
Yauheni Akhotnikau
More information about the Digitalmars-d
mailing list