From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Tue Mar 10 22:12:53 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Tue, 10 Mar 2009 22:12:53 +0100
Subject: [Rd] logical comparison of functions (PR#13588)
In-Reply-To: <49B6D511.2080509@stats.uwo.ca>
References: <20090310203515.74F2D2832196@mail.pubhealth.ku.dk>
	<49B6D511.2080509@stats.uwo.ca>
Message-ID: <49B6D7D5.2000706@idi.ntnu.no>

Duncan Murdoch wrote:
> On 10/03/2009 4:35 PM, michael_karsh at earthlink.net wrote:
>> Full_Name: Michael Aaron Karsh
>> Version: 2.8.0
>> OS: Windows XP
>> Submission from: (NULL) (164.67.71.215)
>>
>>
>> When I try to say if (method==f), where f is a function, it says that
>> the
>> comparison is only possible for list and atomic types.  I tried
>> saying if
>> (method!=f), and it gave the same error message.  Would it be
>> possible to repair
>> it say that == and != comparisons would be possible for functions?
>
> This is not a bug.  Please don't report things as bugs when they
> aren't.  "==" and "!=" are for atomic vectors, as documented.
>
> Use identical() for more general comparisons, as documented on the man
> page for ==.

note that in most programming languages comparing function objects is
either not supported or returns false unless you compare a function
object to itself.  r is a notable exception:

    identical(function(a) a, function(a) a)
    # TRUE

which would be false in all other languages i know;  however,

    identical(function(a) a, function(b) b)
    # FALSE

though they are surely identical functionally.

btw. it's not necessarily intuitive that == works only for atomic vectors.

vQ



[Rd] logical comparison of functions (PR#13588)
Wacek Kusnierczyk