[darcs-users] darcs patch: Replace Autoconf.hs with consistent use of CPP.

Trent W. Buck trentbuck at gmail.com
Thu Feb 19 13:00:15 UTC 2009


On Thu, Feb 19, 2009 at 10:00:22AM +0000, Eric Kow wrote:
> > Thu Feb 19 17:45:16 EST 2009  Trent W. Buck <trentbuck at gmail.com>
> >   * Replace Autoconf.hs with consistent use of CPP.
> >   
> >   It's annoying how recording a patch causes a bunch of unrelated
> >   modules like SHA1 to be recompiled, simply because they use *other*
> >   variables exported by Autoconf.
> 
> Ok in principle, but a quick implementation question:
> 
> Replace Autoconf.hs with consistent use of CPP.
> -----------------------------------------------
> > -{-# INLINE have_libcurl #-}
> > -have_libcurl :: Bool
> > -#ifdef HAVE_CURL
> > -have_libcurl = True
> > -#else
> > -have_libcurl = False
> > -#endif
> 
> Perhaps it would make sense to move definitions like this to the modules
> in which they are used....

I don't think such a definition adds much value, based on the way the
Autoconf variables are currently used.  But if consensus is against
me, I won't fight it.

> > +#if defined(HAVE_LIBWWW) || defined(HAVE_LIBCURL) || defined(HAVE_HTTP)
> >  import URL ( copyUrl, copyUrlFirst, waitUrl )
> > hunk ./src/Darcs/External.hs 71
> > +#endif
> >  import Ssh ( getSSH, copySSH, copySSHs, SSHCmd(..) )
> >  import URL ( Cachable(..) )
> >  import Exec ( exec, Redirect(..), withoutNonBlock )
> > hunk ./src/Darcs/External.hs 222
> >               `catch` \_ -> return Nothing
> >  
> >  speculateRemote :: String -> FilePath -> IO () -- speculations are always Cachable
> > +#if defined(HAVE_LIBWWW) || defined(HAVE_LIBCURL) || defined(HAVE_HTTP)
> 
> thereby avoiding the duplication of our ifdefs?

I'm ambivalent on the aesthetic score, but from a technical standpoint
-- even *if* the never-used branches are optimized away by GHC --
there's still attempts to import (and therefore compile) modules that
might not be used otherwise.  In particular I'm thinking of CString
usage which is only needed in the presence of MAPI or terminfo-less
CURSES.

The sheer number of #ifdef's could also be reduced by shuffling code
around -- I tried to avoid that for this initial patch.


More information about the darcs-users mailing list