From p.dalgaard at biostat.ku.dk  Tue Mar 24 08:52:58 2009
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Tue, 24 Mar 2009 08:52:58 +0100
Subject: [Rd] dput(as.list(function...)...) bug
In-Reply-To: <49C82917.6090409@stats.uwo.ca>
References: <8b356f880903231637v4d5d879dqe51c2d52a73802e4@mail.gmail.com>
	<49C82917.6090409@stats.uwo.ca>
Message-ID: <49C8915A.4070306@biostat.ku.dk>

Duncan Murdoch wrote:
> On 23/03/2009 7:37 PM, Stavros Macrakis wrote:

>  It appears to be the
>> zero-length name:
>>
>>     is.name(ff$x) => TRUE
>>     as.character(ff$x) => ""
> 
> This may give you a hint:
> 
>  > y <- ff$x
>  > y
> Error: argument "y" is missing, with no default
> 
> It's a special internal thing that triggers the missing value error when 
> evaluated.  It probably shouldn't be user visible at all.

Yes, it actually is the zero-length name that is being used for this, 
but that is not really useful knowledge because it is forbidden to 
create them as `` or as.name(""). We did briefly consider making the 
missing object a real R object, but the semantics are too weird:

Basically, you can only assign it once, next time you get errors:

 > x <- alist(a=)$a
 > missing(x)
[1] TRUE
 > y <- x
Error: argument "x" is missing, with no default
 > l <- alist(a=, b=2)
 > l$b <- x
Error: argument "x" is missing, with no default

And, as you think about it, you realize that you cannot disable these 
mechanisms, because _something_ has to trap use of missing arguments.

It does actually work to define a function mvi() which returns the 
missing value indicator and have things like

 > list(x= mvi(), b= quote(!x))
$x


$b
!x

work. I'd hate writing its help page, though.

-- 
    O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



[Rd] dput(as.list(function...)...) bug
Peter Dalgaard