[Rd] print.closure at the R level
Romain Francois
romain.francois at dbmail.com
Mon Apr 20 22:42:22 CEST 2009
Hello,
Sorry if I have waisted any time of people truing this patch. There was
an issue with debugging (use of debug and browser that caused an
infinite recursion). I think this is now fixed.
At the R level, I have now this :
> print.function
function (x, useSource = TRUE, ...)
{
invisible(.Internal(print.function(x, useSource, ...)))
}
<environment: namespace:base>
and the PrintValueRec dispatches like this at the C level:
case LANGSXP:
PrintLanguage(s, FALSE) ;
break;
case CLOSXP:
{
SEXP call;
PROTECT( call = lang2(install("print.function"), s));
eval(call,env);
UNPROTECT(1);
break;
}
so that LANGSXP are printed using the PrintLanguage function and CLOSXP
are printed using the R function print.function which in turns calls the
PrintClosure function (unless it is masked in R)
Romain
Romain Francois wrote:
> Yesterday's patch did not print the attributes. This one seems fine:
>
> > f <- function(){}
> > attr( f, "yada" ) <- function( ) "lobster bisk"
> > f
> function(){}
> attr(,"yada")
> function( ) "lobster bisk"
>
> Romain
>
> Romain Francois wrote:
>> Duncan Murdoch wrote:
>>> On 18/04/2009 10:12 AM, Romain Francois wrote:
>>>> Hello,
>>>>
>>>> Could the code that auto prints a function/closure be extracted
>>>> from print.c so that there would be a print.closure function.
>>>> I would like to be able to mask a print.closure function so that I
>>>> have a custom auto-print. One reason for that is I plan to have
>>>> syntax highlighting within the R console.
>>>
>>> The class of a closure is "function", so you'd want the method to be
>>> print.function. Currently that doesn't work for auto printing, so
>>> your suggestion is still interesting. (I'm not sure why auto
>>> printing is special here...)
>>>
>>> Duncan Murdoch
>> The attached patch implements exposing the print.function at the R
>> level.
>>
>> Romain
>>
>> ------------------------------------------------------------------------
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: printfunction.diff
Type: text/x-patch
Size: 7012 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20090420/a22f3035/attachment.bin>
More information about the R-devel
mailing list