-
-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rcpp::message() ? #1145
Comments
I am not sure I understand what you are writing about. Are you suggesting we need to add If so, why? What current problem does this solve? |
If |
Of course I could roll this myself, I'd rather not. I really think emitting a message from C/C++ code should be easier than the status quo. The |
Ok, now at least I know what we are talking about :) Net additions are easiest; no side effects to existing code. I may have looked into that at some point myself: the (possible) absense of a genuine C API is a spot of bother but we do go via the R API in one or two other places. So having now established that "yes, we could" the burden is now on you to convince Team Rcpp why we should, and burden ourselves with the test and maintenance work going forward. We're listening. |
I really think emitting a message from C/C++ code should be easier than the status quo. There are various ways to solve this:
Unless this is solved here first, I'll eventually go with the third option and propose PRs. |
I still don''t understand.
So has it taken us five messages to establish that you are proposing a C++ function with static instantiation of an R function you want to call? And you still have not addressed the question in my previous post: Why would we need this ? |
I hear you're hesitant to take on new code, perhaps because that's more of a liability than an asset. If I contribute, I add tests and can respond to questions regarding the new code. Personally, I think we need this
Please decide if this is enough motivation, and if it's a good fit for this package. There's no hurry. (Thanks for the fast responses!) |
Less fast response now as we have to sleep sometimes too :) I completely agree on the need for symmetry, I think I wanted it once or twice too. So how do we do it then? I presume you may have looked into the R code? We could do the verboten thing and hitting a hidden API, or we could do the simple thing via |
I had a very very quick look and there is > Rcpp::cppFunction("void foo(std::string s) { R_ShowMessage(s.c_str()); }")
> foo("The quick brown fox")
The quick brown fox
> suppressMessages(foo("The quick brown fox"))
The quick brown fox
> |
And the reason maybe the logic in So ... dunno: do we need two, an (unconditional) |
We can do un-suppressible messages today via |
And ignore So your motivation, which, even ten or so messages in, you don't seem have made clear is that you want a printing / messaging mechanism that can be silenced via |
Using |
Yeah, I'd think that Maybe |
I think we should just call base::message |
I am also puzzled by what Ok, let's wrap |
Looking at the R sources, it looks like However, these "message"s are different from what is exposed to users via |
A truly minimal implementation is here: 8992d83 I am currently rubbing my chin pondering how I would test for (Looks like one can. Nice.) |
You also have |
Hah. Mark and I were DMing and that did not come up. Paging the good Dr @markvanderloo ... |
I guess it affirms that there was a message. Nice. Will add. From the session in which I was noodling: > expect_message( foo("ABC") )
----- PASSED : <-->
call| expect_message(foo("ABC"))
> |
And more: > expect_message(message("asdf"), "ASDF")
----- FAILED[xcpt]: <-->
call| expect_message(message("asdf"), "ASDF")
diff| Found 1 message(s) of class 'message', but not matching 'ASDF'.
diff| Showing up to three messages:
diff| Message 1 of class <simpleMessage, message, condition>:
diff| 'asdf' |
When did the classed messages appear? Would we have to condition this? I think I am fine with the one-liner I just added, but good thinking... |
I think that's a 4.0+ feature, but I was just pointing out that |
True, true, but I did it "in longhand" by calling |
Thanks for taking this on! |
Hi everyone, Please how to include a C++ variable in the message? I mean I have this code currently:
where |
Ah ok, I found std::to_string and one can concatenate the strings with |
Please don't spray random usage questions here in old threads. We do have
|
Ok, sorry, I looked for "Rcpp message" on Google and I found this thread first. I thought my question would be useful for someone else who finds this thread. But ok, sorry again. |
I wonder if
Rcpp::message()
should exist.Rcpp::warning()
forwards toRf_warning()
; since there is noRf_message()
, the new function would take care of callingbase::message()
from R.The text was updated successfully, but these errors were encountered: