From murdoch at stats.uwo.ca  Tue May 29 11:29:51 2007
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Tue, 29 May 2007 05:29:51 -0400
Subject: [Rd] question about R_ParseVector function
In-Reply-To: <dfed1c180705290134w554493b8r89ea4037bc9d2eaf@mail.gmail.com>
References: <dfed1c180705290134w554493b8r89ea4037bc9d2eaf@mail.gmail.com>
Message-ID: <465BF28F.3090706@stats.uwo.ca>

Ev Whin wrote:
> Hi r-devel,
>
> The R_ParseVector has been changed in R-2.5.0, and there is a simple
> description about the 4th argument at
> http://stat.ethz.ch/R-manual/R-patched/NEWS, it says that:
> "R_ParseVector() has a new 4th argument 'SEXP srcfile' allowing source
> references to be attached to the returned expression list. "
> I do not quite understand the purpose of adding the 4th argument. Would some
> experts explain this function in details?

The 4th argument isn't used by the parser, but it is carried along and 
attached to the output as part of the source reference in a srcref 
attribute.  The normal use would be a srcfile() object, or NULL for nothing.

Source references are currently used instead of deparsing when 
available, so that if a user parses something like

x    <-    1 # comment
y    <-    2

the comment and strange formatting aren't lost when displaying the code.

In the long term, I hope to also be able to use the source references in 
a source level debugger:  they allow R to know where the code comes from 
as it is executing it, so the display could allow single stepping 
through the original source file, rather than through a deparsed version 
of the code.  It's also possible that run-time errors could report the 
location of the line of code that triggered them.

Duncan Murdoch



[Rd] question about R_ParseVector function
Duncan Murdoch