From hb at stat.berkeley.edu  Tue Jan 16 22:41:45 2007
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Wed, 17 Jan 2007 08:41:45 +1100
Subject: [Rd] on.exit called on loading ?
In-Reply-To: <17837.15696.636229.572815@basebud.nulle.part>
References: <17837.15696.636229.572815@basebud.nulle.part>
Message-ID: <59d7961d0701161341p56a6e835h976151743665de25@mail.gmail.com>

on.exit() applies to the function where it was called, i.e.
closeSomeServices() is called when .onLoad() exits, or whatever
function it is defined in.  You're looking for .onUnload().  Make sure
to read the help for details.

Cheers

Henrik


On 1/17/07, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> I just found out that an .onLoad() function such as this stylized one (where
> I just renamed some identifiers)
>
>
> .onLoad <- function(lib, pkg) {
>   require(zoo, quiet=TRUE, warn.conflicts=FALSE)
>   library.dynam("foolib", pkg, lib )
>   if (.Platform$OS.type != "windows") {
>     initSomeServices()
>   }
>   if (.Platform$OS.type != "windows") {
>     on.exit(closeSomeServices())
>   }
> }
>
> actually triggers a call of 'closeSomeServices()'. I am probably
> misunderstanding something here -- but I thought on.exit() would only be
> called on, well, exit ?
>
> Dirk
>
> --
> Hell, there are no rules here - we're trying to accomplish something.
>                                                   -- Thomas A. Edison
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] on.exit called on loading ?
Henrik Bengtsson