Skip to content

Rf_protect in Rinternals.h

2 messages · Hans-Peter, Brian Ripley

#
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?

Thanks for some enlightenment...

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

            
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).