Considering these new insights from Romain and Duncan, a good project might
be to revisit package.skeleton, using the parser package. This reminds me of
a recent proposal of parsing Rd files to convert them into roxygen tags in
the source code.

Thanks for the input,

baptiste




2009/8/31 Duncan Murdoch <murd...@stats.uwo.ca>

> baptiste auguie wrote:
>
>> 2009/8/31 David Scott <d.sc...@auckland.ac.nz>
>>
>>
>>
>>> I think this discussion is valuable, and have previously asked about
>>> style
>>> which I think is very important. Base R does suffer from very
>>> inconsistent
>>> naming and as I think Duncan said it makes it very difficult sometimes to
>>> remember names when you have variations in case and separators as with
>>> things related to system.
>>>
>>> David
>>>
>>>
>>>
>>>
>> Is it a foolish idea to think that perhaps code could be checked and
>> re-formatted automatically when building a package?
>>
>>
> Building a package is the wrong time:  this is something that should be
> done by the author, to the source, before building, but it's quite hard.
>  What you're talking about is a "pretty printer" or "code beautifier".  One
> tricky bit is handling comments, another is handling idiosyncratic
> formatting.  For example, I often line up things on successive lines just so
> that it's easy to see differences I consider important, e.g. in tables of
> constants, etc.
>
> Duncan Murdoch
>
>  Say, I write a function like this,
>>
>> this.is.my.name = function(
>>   a = 1,b=2,
>>  # i'm a comment
>>   z=F)
>> {
>> if(T)
>> {
>> print("true")
>> } else
>> {
>> print("else")
>> }
>>
>> }
>> package.skeleton automatically converts the first "=" sign to "<-" and
>> sometimes also adds backquotes `` to protect the function name. Could this
>> be extended in a few ways,
>>
>> 1- rationalise the function naming scheme, e.g convert every function name
>> to camelCase (and provide aliases not to break dependencies)
>>
>> 2- indent the code and add spaces around commas
>>
>> 3- tidy up the position of braces to make it consistent
>>
>> 4- convert T and F to TRUE and FALSE, this sort of things
>>
>> 5- finally, run a comparison of the two versions to check that the
>> behaviour
>> is as intended.
>>
>> 1,2,3 could be tuned according to a template that the user chooses for a
>> given package (some may prefer underscores, etc.)
>>
>>
>> Perhaps I'm dreaming a bit here, this sounds like meta-programming.
>>
>>
>> Best,
>>
>> baptiste
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>


-- 
_____________________________

Baptiste AuguiƩ

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

http://newton.ex.ac.uk/research/emag
______________________________

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to