From gchappi at gmail.com  Thu Feb 16 17:37:56 2006
From: gchappi at gmail.com (Hans-Peter)
Date: Thu, 16 Feb 2006 17:37:56 +0100
Subject: [Rd] Rf_errorcall - translate to Pascal
In-Reply-To: <Pine.LNX.4.64.0602161235070.12709@gannet.stats.ox.ac.uk>
References: <47fce0650602160055y33a4c253r@mail.gmail.com>
	<47fce0650602160247w58a5f770s@mail.gmail.com>
	<Pine.LNX.4.64.0602161235070.12709@gannet.stats.ox.ac.uk>
Message-ID: <47fce0650602160837g259799ar@mail.gmail.com>

Hello!

Thanks for your answers!

---
2006/2/16, Duncan Murdoch <murdoch at stats.uwo.ca>:
> I think it would be helpful to know the scope of the problem.  Could you
> collect together a complete list of examples like this?

yes, I will do that. Until now it's only the one function mentioned
and the 2 macro groups.
Btw: your Delphi notes were great to get me started !!!

---
2006/2/16, Rainer M Krug <rkrug at sun.ac.za>:
> Hans-Peter wrote:
> > I (try to) convert the external R header files to Pascal (Delphi). At
> Sounds interesting - Could you keep me updated about your progress? I
> would be interested in the header files to use them in the analysis of
> simulations from Delphi.

Sure, but I cannot promise anything. I did the same for Matlab but
it's much more difficult with R.

---
2006/2/16, Prof Brian Ripley <ripley at stats.ox.ac.uk>:
> Yes, and their names are case-sensitive too.  So it is intentional that
> errorcall is not in R_Ext/Error.h.  Since it is needed for writing
> front-ends and now mentioned in Writing R Extensions it should probably be
> in Rinternals.h.

that would be great!

>But note that is basically the only way that a non-core
> programmer is going to be writing code that gets passed 'call' objects.

ok, thanks

> > As a sidenote: in Defn.h are two macrogroups:
> This is intentional.  Both Defn.h and Rinternals.h have these in a section
> protected by
> #ifdef USE_RINTERNALS
> #endif
> and that section should not be regarded as public.

I know that USE_RINTERNALS is ...internal and can change. But I had to
translate it nevertheless, because I need at least the type definition
"SEXP". And e.g. in chapter "4.8.2 Calling .External" there are code
samples with the macros CADR, TYPEOF, CHAR, STRING_ELT, ... which
AFAIK can run in Pascal only if they are redefined as pascal
functions. Regarding the possible changes I have to think about DUnit
tests to catch them.

>There _are_ (mis-titled) sections
> /* Promise Access Macros */
> /* Hashing Macros */
> in Rinternals.h, and those are the function equivalents defined for
> external use.

Sorry, I don't understand. Eg. in Rinternals.h the first entry in /*
Promise Access Macros */ is:   SEXP (PRCODE)(SEXP x);
                 ~~~~~~~
Do you now mean, that the macro PRCODE is defined for external use? 
On the other hand, it's nowhere in the "writing R extensions
documentation". But it's e.g. used in the library methods (in the
function: methods-List_dispatch.c).

If its meant for external use, then AFAIK the only way to use this
macro in Pascal code is to translate it as a function, like e.g.:

  function rhPrcode( _x: pSexp ): pSexp;
    begin
      result:= _x.promsxp.expr;
    end;

<license related>
And now it's a bit unnice, that "_x.promsxp.expr" is defined in Defn.h
[as: ((x)->u.promsxp.expr)] and not in Rinternal.h. With almost all
other macros, e.g. FORMALS this is different, they are defined in
Rinternal.h [e.g.: ((x)->u.closxp.formals)]. In this macro case I
think its also for strict license interpretations irrelevant, because
SEXPREC and promsxp_struct are fully declared in Rinternal.h. But it's
not nice and maybe I just skip it.
</license related>


--
Regards,
Hans-Peter



[Rd] Rf_errorcall - translate to Pascal
Hans-Peter