Comments on DMD frontend.

Leandro Lucarella llucax at gmail.com
Sat Feb 23 22:25:15 PST 2008


Hi. I'm starting to play arround with the DMD frontend bundled with the
compiler.

My firt big surprise, and not a good one, was that the frontend files are
named with the .c extension, instead of .cpp, .cxx, or anything used for
C++ files. Is there a rationale behind that? I find it very confusing.

Second, I saw the code has a lot of:
#if DEBUG
printf(...);
#endif

(LOG or simply 0 are used too)

This is really annoying and can easily be changed for something like:
#if DEBUG
#    define debug(...) printf(__VA_ARGS__)
#else
#    define debug(...)
#endif

(I know macros with variable arguments are just in C99, but I think most
compilers has a vendor-specific way of doing it)

And then just write: debug(...);

This makes the code much more readable.

In some places there's a sightly more complicated:
#if DEBUG
if (condition)
	printf(...);
#endif

which can be solved by adding a new macro, for example "cdebug" (c for
conditional):

#if DEBUG
#    define cdebug(c, ...) ((c) && printf(__VA_ARGS__))
#else
#    define cdebug(c, ...)
#endif

And just writing: cdebug(condition, ...);

If you are willing to accept a patch that implement this, I'm willing to
do it.

And please, can you please, please consider on putting the frontend on a
SCM? (git would be great, dsource's svn is ok :).

Thanks!

-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Fitter, happier, more productive, comfortable, not drinking too much,
regular exercise at the gym (3 days a week),
getting on better with your associate employee contemporaries,



More information about the Digitalmars-d mailing list