From Kurt.Hornik@ci.tuwien.ac.at  Sun Feb 13 15:48:14 2000
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Sun, 13 Feb 2000 16:48:14 +0100
Subject: [Rd] 0.99
In-Reply-To: <38A07AF8.E9A7BFF5@nceas.ucsb.edu>
References: <38A07AF8.E9A7BFF5@nceas.ucsb.edu>
Message-ID: <200002131548.QAA29082@aragorn.ci.tuwien.ac.at>

>>>>> Timothy H Keitt writes:

> Congrats on the new release.  The new package management tools are
> great!

> A couple of quick comments:

> 1) it might be nice to add an optional "Autoloads:" field to the
> description (the package does not depend on these other packages, but
> will autoload them if certain functions are called).

> 2) on page 3 of the R-exts document, it says to set PKG_* flags in
> 'Makeconf'; I think this should read 'src/Makevars'

Fixed, thanks.

> (this paragraph in general is pretty awkward reading).

Feel free to suggest improvements ...

> 3) I prefer PKG_LDFLAGS for the "-L" stuff and PKG_LIBS for the "-l"
> statements (currently the docs say to put it all in PKG_LIBS).

And I'd prefer to keep it like that.  As I think I already mentioned,
the naming is patterned after autoconf, which distinguishes

 - Variable: LDFLAGS
     Stripping (`-s') and any other miscellaneous options for the
     linker.

 - Variable: LIBS
     `-l' and `-L' options to pass to the linker.

> 4) page 5 of R-exts gives an example of using autoconf to
> enable/disable R functions depending on whether or not a library is
> available; currently it suggests putting a test in the body of the
> function that is executed every time the function is called, even if
> the external library exists.  This is confusing flow control with
> conditional compilation.  Perhaps the example could be reworked so
> that the function itself is defined differently depending on whether
> or not the external library is found. (If the library does not exist,
> the function is defined to return an error; otherwise define the
> function normally.)

You mean to have

  if(@HAVE_FOO@) {
     foo <- function(x) { ... }
  }
  else {
     foo <- function(x) { stop("...") }
  }

???

That's obviously more efficient, but (as far as I am concerned) not yet
optimal, as it results in ugly conditional code.  When using autoconf, I
think it is far better to use fragments, roughly along the following
lines.  In configure.in, do

  if test "${HAVEFOO}" = TRUE; then
    foo_frag=R/frag/code-for-foo-T.R
  else
    foo_frag=R/frag/code-for-foo-F.R
  fi
  AC_SUBST_FILE(foo_frag)

In one of the .R.in files in the R dir, you can then do

  @foo_frag@

and get configure-time conditional inclusion without any run-time
testing.

(I did not test whether the above works ... can someone please do that?
I will then modify R-exts.texi accordingly.)

Thanks,
-k

  
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] 0.99
Kurt Hornik