[Rd] as.missing

Paul Gilbert pgilbert at bank-banque-canada.ca
Fri Oct 27 17:38:05 CEST 2006



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




More information about the R-devel mailing list