From ripley at stats.ox.ac.uk  Wed Feb  8 20:09:46 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 8 Feb 2006 19:09:46 +0000 (GMT)
Subject: [Rd] Rf_protect in Rinternals.h
In-Reply-To: <47fce0650602080907q39738247w@mail.gmail.com>
References: <47fce0650602080907q39738247w@mail.gmail.com>
Message-ID: <Pine.LNX.4.64.0602081831110.27091@gannet.stats.ox.ac.uk>

On Wed, 8 Feb 2006, Hans-Peter wrote:

> Hello!
>
> I'd like to ask you a question about c (macros):
>
> In Rinternals.h are defined:
> a)   SEXP Rf_protect(SEXP);
> b)   #define protect Rf_protect
> c)   #define PROTECT(s)	protect(s)
>
> As far as I understand the calls Rf_protect( x ), protect( x ) and
> PROTECT( x ) are all equalent.
>
> So whats the reason that there are 2 macros defined? Why 3 times the
> same when 1 distinct function would be enough?

History.  People do not like writing 'Rf_protect', so PROTECT is used 
instead.  And the code is written as 'protect' for the same reason, and to 
allow future changes under the skin.  (Several macros are in fact used 
differently inside R, and Rinternals.h was an attempt to extract a 
reasonable subset of the internal code, not an ab initio design).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Rf_protect in Rinternals.h
Prof Brian Ripley