From pdalgd at gmail.com  Fri Oct  5 08:34:13 2012
From: pdalgd at gmail.com (peter dalgaard)
Date: Fri, 5 Oct 2012 08:34:13 +0200
Subject: [Rd] How to build a list with missing values? What is missing,
	anyway?
In-Reply-To: <CAJoaRhYaRyoSzCKWgNNsuo63BazcG_CPDaAW_o4bXMMTeUdeLA@mail.gmail.com>
References: <CAJoaRhb8gq79aB3EXPeMa+n6eK6pj9NTFHFBJRUbP_=S1bbTaA@mail.gmail.com>
	<1349331704206-4644965.post@n4.nabble.com>
	<CAJoaRhbgikc=3Gpa8LAvSakjE=e95Z5akS7w5dHEND+yWHfJ6Q@mail.gmail.com>
	<CACk-te23paBonBtKY+eNoqVVdz_0186Y-DnfaMQ4zJOsZS-Gww@mail.gmail.com>
	<CAJoaRhYaRyoSzCKWgNNsuo63BazcG_CPDaAW_o4bXMMTeUdeLA@mail.gmail.com>
Message-ID: <7BF47B8D-A110-4BD3-BEE5-ACE46D7D52A4@gmail.com>


On Oct 5, 2012, at 03:31 , Peter Meilstrup wrote:

> On Thu, Oct 4, 2012 at 6:12 PM, Bert Gunter <gunter.berton at gene.com> wrote:
>> The R Language definition manual explains all of this. Read it.
> 
> I always reread that before I post to this list.
> 
> The only relevant mention of "missing" in the R Language Definition
> that I could find were in section 4.1.2 on page 25, and that section
> did not answer anything about "missing" as a special symbol (e.g. that
> my be put in a formal argument list.)

It's not defined as an R object. We did consider doing so briefly, but the semantics would be weird, as you have experienced: An R object that can't be evaluated without triggering an error. 

It is something that is used by the internals, so that missing values propagate with lazy evaluation semantics. It happens to be implemented as the equivalent of as.name(""), but that's not to be relied upon. It leaks out into user space because arguments can have missing defaults, and there needs to be a way to manipulate argument lists. It also slips out in substitute() with no argument, and I suppose that too is at least semi-intentional. It is not completely obvious that the two are necessarily identical.

It's one of those things where you shouldn't rely on behavior outside of well-establihed idioms. If you do, and it breaks, you get to keep both pieces...

I suppose we could try documenting it better, but it would be at the risk of authorizing semantics that we might want to change (e.g., it is far from clear that we should be allowing direct assignment of missings to simple symbols).

("..." and friends is a somewhat different kettle of fish which I don't want to go into just now.)

-pd

> There is another mention of `...` in section 4.3.2 and it does not
> explain some things, such as under what circumstances one would get a
> "`...` used in incorrect context" error.
> 
> Peter
> 
>>> 
>>> Thanks.
>>> 
>>> Just so I have my mental model correct, I'm gathering that missing/``
>>> is a symbol that the interpreter has a special rule for -- evaluating
>>> it raises an error, as opposed to objects that evaluate to themselves
>>> or variable names that evaluate to objects.
>>> 
>>> Does the same sort of thing explain the behavior of `...`? When the
>>> interpreter comes across `...` in the arguments during evaluation of a
>>> call, it trips a special argument-interpolating behavior?
>>> 

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] How to build a list with missing values? What is missing, anyway?
peter dalgaard