From ripley at stats.ox.ac.uk  Wed Jul 11 14:17:16 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Wed, 11 Jul 2007 13:17:16 +0100 (BST)
Subject: [Rd] Getting param names of primitives
In-Reply-To: <18068.45289.14125.872148@stat.math.ethz.ch>
References: <d35b9da60707102141q60586e66w88a4b991595edcd0@mail.gmail.com>
	<Pine.LNX.4.64.0707110546480.27029@gannet.stats.ox.ac.uk>
	<18068.45289.14125.872148@stat.math.ethz.ch>
Message-ID: <Pine.LNX.4.64.0707111314380.5891@gannet.stats.ox.ac.uk>

My problem is that if we make formals() work on primitives, people will 
expect

formals(log) <- value

to work, and it cannot.

On Wed, 11 Jul 2007, Martin Maechler wrote:

>>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk>
>>>>>>     on Wed, 11 Jul 2007 05:48:56 +0100 (BST) writes:
>
>    >> formals(args(log))
>    BDR> $x
>
>
>    BDR> $base
>    BDR> exp(1)
>
>    BDR> gives what formals(log) used to.
>
> (I knew). I've been asking myself several times now,
> if we should not make
> formals() do this automatically.
> I know that the change might break some code
> which has used things like
>
> if(is.null(formals(fun))) {
>
>  ## treat  fun  as a primitive function
>
> }
>
> but I think R has provided  is.primitive(.)
> long enough now so that
> we could consider the change.
>
> Martin
>
>
>    BDR> On Wed, 11 Jul 2007, miguel manese wrote:
>
>    >> Hi,
>    >>
>    >> In the latest R this does not work anymore
>    >>
>    >> args <- formals(log)
>    >>
>    >> because log is primitive. Is there any other way to get the argument
>    >> list? I just need the name of the parameter to display some error
>    >> message about it. I have looked at args() but I can't find anything to
>    >> extract the argument names from it.
>    >>
>    >> Thanks,
>    >> M. Manese
>
>    BDR> --
>    BDR> Brian D. Ripley,                  ripley at stats.ox.ac.uk
>    BDR> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>    BDR> University of Oxford,             Tel:  +44 1865 272861 (self)
>    BDR> 1 South Parks Road,                     +44 1865 272866 (PA)
>    BDR> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
>    BDR> ______________________________________________
>    BDR> R-devel at r-project.org mailing list
>    BDR> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Getting param names of primitives
Prof Brian Ripley