From pgilbert at bank-banque-canada.ca  Fri Oct 27 17:53:33 2006
From: pgilbert at bank-banque-canada.ca (Paul Gilbert)
Date: Fri, 27 Oct 2006 11:53:33 -0400
Subject: [Rd] as.missing
In-Reply-To: <x2mz7hzs0a.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>	<4542260D.2000606@bank-banque-canada.ca>
	<x2mz7hzs0a.fsf@turmalin.kubism.ku.dk>
Message-ID: <45422B7D.204@bank-banque-canada.ca>



Peter Dalgaard wrote:

>Paul Gilbert <pgilbert at bank-banque-canada.ca> writes:
>
>  
>
>>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?
>>>      
>>>
>>Yes.  The value of x in g would get passed to f, default or otherwise.
>>If that value is something that indicates x is missing, then it should
>>be treated as if it is missing in f. This means f should use its
>>default value, rather than throw an error saying x is missing.
>>
>>    
>>
>>>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.
>>>
>>>      
>>>
>>You understand this better than I do, but I don't think I am asking to
>>do this. Currently I think f  looks back too far and finds x is
>>missing and g does not have a default value for x, so it throws an
>>error.  Why can't f find its own default value for x?
>>    
>>
>
>Because it's being told to use the value of the argument instead. I
>think. 
>
>This stuff is treacherous. E.g. what would you expect from this?
>
>g <- function(x) {f <- function(y) {x <<- 1; y} ; f(x)}
>g()
>
>  
>
I'm confused.  Neither f nor g have a default here, so I don't think 
this is related to what I'm talking about. Currently, in your example, f 
find x with a value of 1, and I am not suggesting changing that. I'm 
only suggesting that if f finds x is missing, it should look at it's own 
default argument.
====================================================================================

La version fran?aise suit le texte anglais.

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

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




[Rd] as.missing
Paul Gilbert