From murdoch at stats.uwo.ca  Fri Oct 27 17:23:55 2006
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Fri, 27 Oct 2006 11:23:55 -0400
Subject: [Rd] as.missing
In-Reply-To: <x2pscdltv9.fsf@turmalin.kubism.ku.dk>
References: <453E462C.6050103@bank-banque-canada.ca>	<971536df0610250928q615c2e4dl950e8f576c492789@mail.gmail.com>	<4540CC71.1010108@bank-banque-canada.ca>	<971536df0610261830o4d36376bk4b90d42e218eb2d0@mail.gmail.com>	<m0hcxq3z2a.fsf@bar.nemo-project.org>	<45420FE2.5090000@bank-banque-canada.ca>
	<x2pscdltv9.fsf@turmalin.kubism.ku.dk>
Message-ID: <4542248B.2040703@stats.uwo.ca>

On 10/27/2006 10:24 AM, Peter Dalgaard wrote:
> Paul Gilbert <pgilbert at bank-banque-canada.ca> writes:
> 
>> >I.e., when x is missing in g, and g calls f(3,x), f will use its
>> >default value for x.
>> >  
>> >
>> Yes, that is the behaviour I am looking for. That is, f  should do what 
>> it normal would do if it were called with x missing.
> 
> But if x has a default in g then that default should presumably be
> used? And what if x is given a value in the evaluation frame of g
> before it is used by f (which can happen, you know, even after the
> evaluation of f has begun)? Now imagine a longer chain of calls.
> 
> I think what you're asking for is essentially dynamic scoping for
> missing arguments: you'd have to backtrack along the call chain to
> find the first instance where x is either given a value or has a
> default. This sounds messy.

I've been meaning to look at the code to see how this is handled now, 
but haven't had a chance yet.  I would guess at some level there's a 
test something like

if (name not in actualarglist) treat as missing
else treat as present

I think Paul's suggestion could be implemented by making this just a bit 
more complicated:

if (name not in actualarglist || get(name) == SpecialMissingValue) treat 
as missing
else treat as present

where SpecialMissingValue is what as.missing() returns.

So if my guess is right, this would be fairly easy to implement.  But 
it's also possible that this test shows up implicitly in many places, in 
which case it would be a lot messier.

Duncan Murdoch




[Rd] as.missing
Duncan Murdoch