From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Sun Feb 22 22:08:05 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Sun, 22 Feb 2009 22:08:05 +0100
Subject: [Rd] 'unique' error message is printed
	despite	silent=TRUE	(PR#13547)
In-Reply-To: <49A1B292.1070908@biostat.ku.dk>
References: <20090222191519.17912282C76C@mail.pubhealth.ku.dk>
	<49A1B292.1070908@biostat.ku.dk>
Message-ID: <49A1BEB5.6050701@idi.ntnu.no>

Peter Dalgaard wrote:
> macrakis at alum.mit.edu wrote:
>>

<snip>

>>> try(.Internal(unique(quote(hello),NULL,NULL)),silent=TRUE)
>> hello
>>
>> I guess it is using the internal equivalent of print rather than the
>> internal equivalent of stop.
>>
>
> silent=TRUE is a red herring (this has nothing to do with try()).
>
> However, inside do_duplicated (unique.c) we have
>
>     if (!isVector(x)) {
>     PrintValue(x);
>     error(_("%s() applies only to vectors"),
>           (PRIMVAL(op) == 0 ? "duplicated" : "unique"));
>     }
>
> This is due to
>
> ------------------------------------------------------------------------
> r32306 | ripley | 2004-12-23 22:06:27 +0100 (Thu, 23 Dec 2004) | 2 lines
>
> Apparently unique/duplicated are supposed to work on NULL, despite
> their help!
>
> ...which makes little sense to explain the PrintValue(x). I suspect
> this is a debugging printout that was inadvertently left in.

hmm, why wouldn't you use something like

    DEBUG(x)

with DEBUG being a macro defined so that it's replacement is void unless
a specific flag or environment variable is set specifically for the
purpose of debugging?  you would then avoid confusing users' code just
because one PrintValue has been inadvertently left in the sources.


vQ



[Rd] 'unique' error message is printed despite silent=TRUE (PR#13547)
Wacek Kusnierczyk