macrakis at alum.mit.edu
2009-Feb-22 19:15 UTC
[Rd] 'unique' error message is printed despite silent=TRUE (PR#13547)
In 2.8.0/Windows Vista: When 'unique' gives a type error message, it prints out even if errors are being caught:> try(unique(quote(hello)),silent=TRUE)hello This comes from the .Internal unique routine:> 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. -s
Duncan Murdoch
2009-Feb-22 20:06 UTC
[Rd] 'unique' error message is printed despite silent=TRUE (PR#13547)
On 22/02/2009 2:15 PM, macrakis at alum.mit.edu wrote:> In 2.8.0/Windows Vista: > > When 'unique' gives a type error message, it prints out even if errors > are being caught: > >> try(unique(quote(hello)),silent=TRUE) > hello > > This comes from the .Internal unique routine: > >> 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.Still there in R-devel; I'll see if I can fix it. Duncan Murdoch
Wacek Kusnierczyk
2009-Feb-22 20:06 UTC
[Rd] 'unique' error message is printed despite silent=TRUE (PR#13547)
macrakis at alum.mit.edu wrote:> In 2.8.0/Windows Vista: > > When 'unique' gives a type error message, it prints out even if errors > are being caught: > > >> try(unique(quote(hello)),silent=TRUE) >> > hello > > This comes from the .Internal unique routine: > > >> 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. > >line 454+ in src/main/unique.c: if (!isVector(x)) { PrintValue(x); error(_("%s() applies only to vectors"), (PRIMVAL(op) == 0 ? "duplicated" : "unique")); } in your example, quote() produces a non-vector, hence the output before the error message. vQ
Peter Dalgaard
2009-Feb-22 20:16 UTC
[Rd] 'unique' error message is printed despite silent=TRUE (PR#13547)
macrakis at alum.mit.edu wrote:> In 2.8.0/Windows Vista: > > When 'unique' gives a type error message, it prints out even if errors > are being caught: > >> try(unique(quote(hello)),silent=TRUE) > hello > > This comes from the .Internal unique routine: > >> 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. -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
murdoch at stats.uwo.ca
2009-Feb-22 21:20 UTC
[Rd] 'unique' error message is printed despite silent=TRUE (PR#13547)
On 22/02/2009 4:08 PM, Wacek Kusnierczyk wrote:> 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.But then we'd confuse developers, who would see a huge dump of messages from every other debugging session, when they just wanted to see their own, and who would be forced to wade through leftover never-used DEBUG(x) calls in code when they were reading the source. This is not a common error: as far as I know, there are no other unintentional PrintValue calls anywhere in the source. So I think the current system (just take them out before committing) is working. Duncan Murdoch
Maybe Matching Threads
- [LLVMdev] [LLVM, llvm-diff] Question about FunctionDifferenceEngine and DiffConsumer::printValue
- [LLVMdev] [LLVM, llvm-diff] Question about FunctionDifferenceEngine and DiffConsumer::printValue
- [LLVMdev] [LLVM, llvm-diff] Question about FunctionDifferenceEngine and DiffConsumer::printValue
- [LLVMdev] [LLVM, llvm-diff] Question about FunctionDifferenceEngine and DiffConsumer::printValue
- printing reals from C with digits -- once more