From simon.urbanek at r-project.org  Thu Sep  4 16:17:47 2008
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu, 4 Sep 2008 10:17:47 -0400
Subject: [Rd] suggestion of new API function for embedded programming.
In-Reply-To: <twig.1220449912.10283@swcp.com>
References: <twig.1220449912.10283@swcp.com>
Message-ID: <B00171C0-EBC2-477F-9D0E-A676FFE62B0C@r-project.org>


On Sep 3, 2008, at 9:51 , EBo wrote:

>
> While doing some embedded programming and trying to figure out how  
> to generate
> a hand coded SEXP equivalent of the line
> "t.test(x,conf.level=(1-p))$conf.int[2]" I had an idea for an  
> addition to the
> embedded API.
>
> There are a number of hidden or static parse functions (R_ParseBuffer,
> R_Parse1Buffer, etc.) which take an IoBuffer* and returns a parsed  
> tree.  If
> one or more of these functions were exported to the Rembedded.h API  
> we could
> do something like the following:
>
>  R_Expr = R_Parse1Buffer(&R_ConsoleIob, 0, &status);
>  if (PARSE_OK==status) {
>    ...
>    value = eval(R_CurrentExpr, rho);
>    ...
>  }
>
> or possibly simplifying the interface to take the CMDL string:
>
>  R_Expr = R_Parse1Line("t.test(x,conf.level=(1-p))$conf.int[2]",  
> &status);
>

Why do you think is R_ParseVector not sufficient for this? That is  
what most of use use to achieve exactly what you describe...
For something that even mimics the continuation behavior of the R  
console have a look at parseString function in Rserve.

Cheers,
Simon


> I think this would be a useful addition to the embedding interface,  
> and
> hopefully not difficult to incorporate by someone more experienced  
> with the
> internals than I currently am.  I took a few hours to look into  
> adding this
> interface, but will not have time to try to do so for a few months  
> -- I have a
> couple of hard and fast deadlines over the next couple of weeks.   
> So, I would
> like to make the suggestion and participate in the dialog.
>
>  Best regards,
>
>  EBo --
>
> ps: if someone can suggest how to hand code
> "t.test(x,conf.level=(1-p))$conf.int[2]" so I can embedd it I would  
> be most
> appreciative.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



[Rd] suggestion of new API function for embedded programming.
Simon Urbanek