From pgilbert at bank-banque-canada.ca  Fri Oct 27 17:38:05 2006
From: pgilbert at bank-banque-canada.ca (Paul Gilbert)
Date: Fri, 27 Oct 2006 11:38:05 -0400
Subject: [Rd] as.missing
In-Reply-To: <4542248B.2040703@stats.uwo.ca>
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>
	<4542248B.2040703@stats.uwo.ca>
Message-ID: <454227DD.3000405@bank-banque-canada.ca>



Duncan Murdoch wrote:

> 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.

Great! Let's hope it is not messy.  BTW, I don't have any special reason 
to think as.missing() should be a function. It could be a special  
defined constant.

>
> Duncan Murdoch
====================================================================================

La version fran?aise suit le texte anglais.

------------------------------------------------------------------------------------

This email may contain privileged and/or confidential inform...{{dropped}}




[Rd] as.missing
Paul Gilbert