Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-30 Thread 良无
Thanks! jl_error() is what I want here.

This might help:
>
> http://docs.julialang.org/en/release-0.3/manual/embedding/#throwing-julia-exceptions
>
> On Wed, Dec 24, 2014 at 10:41 PM, 良无 > 
> wrote:
>
>> In C or C++ code, I have a function:
>>
>> void funcname(...){
>>...
>>assert(0);
>>...
>> }
>>
>>  if I run `ccall((:funcname, libpath), Void, (...), ...)` in Julia , it 
>>  will  terminate the Julia process.
>>
>> How can I replace assert() with other function to throw an error in Julia?
>>
>>
>> > ccall((:funcname, libpath), Void, (...), ...)
>>
>> ERROR: 
>>
>> I am sorry that I can not make it clear, and I just come to Julia from 
>> the R world.  
>>
>> Thanks.  ;-) 
>>
>> I'm afraid I still don't get it. What do you want to do?
>>>
>>>
>>> On Dec 24, 2014, at 8:15 PM, 良无  wrote:
>>>
>>> If you want to release an R package to CRAN, R Core will force you to 
>>> check this by R CMD check:
>>>
>>> - Compiled code should never terminate the R process within which it is 
>>> running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and 
>>> so on must be avoided. Nor may R code call q().
>>>
>>>
>>> Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit : 
 > In my origin C++ code, I use assert(), but if I want to use this code 
 > in Julia, maybe I need to replace it with other functions. In R, I 
 can 
 > use Rcpp::stop(). Is there any easy way to do it in Julia with C or C 
 > ++ code. 
 IIUC, you want to raise a Julia exception from C code, right? 

 > And it seems that Julia does not have R CMD check like stuff yet. It 
 > does not check this kind of issue. 
 You mean, running a test suite? See 
 http://docs.julialang.org/en/latest/stdlib/test/ 

 and how most packages do this, for example 
 https://github.com/JuliaStats/StatsBase.jl/tree/master/test 


 Regards 

>>>
>

Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Stefan Karpinski
Ah, in that case Isaiah's answer is spot on.

On Wed, Dec 24, 2014 at 11:59 PM, Elliot Saba  wrote:

> No, I think what is wanted here is an analogue to Rcpp::stop(), which looks
> like it throws an R error
> 
>  from
> within C/C++ code.  I believe the intent here is to generate
> high-level-language errors from low(er)-level-language libraries.
> -E
>
> On Wed, Dec 24, 2014 at 8:47 PM, Stefan Karpinski 
> wrote:
>
>> Isn't it the opposite of that though? I.e. catching C++ assert failures?
>>
>> On Wed, Dec 24, 2014 at 11:46 PM, Isaiah Norton 
>> wrote:
>>
>>> This might help:
>>>
>>> http://docs.julialang.org/en/release-0.3/manual/embedding/#throwing-julia-exceptions
>>>
>>> On Wed, Dec 24, 2014 at 10:41 PM, 良无  wrote:
>>>
 In C or C++ code, I have a function:

 void funcname(...){
...
assert(0);
...
 }

  if I run `ccall((:funcname, libpath), Void, (...), ...)` in Julia , it
  will  terminate the Julia process.

 How can I replace assert() with other function to throw an error in
 Julia?


 > ccall((:funcname, libpath), Void, (...), ...)

 ERROR: 

 I am sorry that I can not make it clear, and I just come to Julia from
 the R world.

 Thanks.  ;-)

 I'm afraid I still don't get it. What do you want to do?
>
>
> On Dec 24, 2014, at 8:15 PM, 良无  wrote:
>
> If you want to release an R package to CRAN, R Core will force you to
> check this by R CMD check:
>
> - Compiled code should never terminate the R process within which it
> is running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP
> and so on must be avoided. Nor may R code call q().
>
>
> Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit :
>> > In my origin C++ code, I use assert(), but if I want to use this
>> code
>> > in Julia, maybe I need to replace it with other functions. In R, I
>> can
>> > use Rcpp::stop(). Is there any easy way to do it in Julia with C or
>> C
>> > ++ code.
>> IIUC, you want to raise a Julia exception from C code, right?
>>
>> > And it seems that Julia does not have R CMD check like stuff yet.
>> It
>> > does not check this kind of issue.
>> You mean, running a test suite? See
>> http://docs.julialang.org/en/latest/stdlib/test/
>>
>> and how most packages do this, for example
>> https://github.com/JuliaStats/StatsBase.jl/tree/master/test
>>
>>
>> Regards
>>
>
>>>
>>
>


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Elliot Saba
No, I think what is wanted here is an analogue to Rcpp::stop(), which looks
like it throws an R error

from
within C/C++ code.  I believe the intent here is to generate
high-level-language errors from low(er)-level-language libraries.
-E

On Wed, Dec 24, 2014 at 8:47 PM, Stefan Karpinski 
wrote:

> Isn't it the opposite of that though? I.e. catching C++ assert failures?
>
> On Wed, Dec 24, 2014 at 11:46 PM, Isaiah Norton 
> wrote:
>
>> This might help:
>>
>> http://docs.julialang.org/en/release-0.3/manual/embedding/#throwing-julia-exceptions
>>
>> On Wed, Dec 24, 2014 at 10:41 PM, 良无  wrote:
>>
>>> In C or C++ code, I have a function:
>>>
>>> void funcname(...){
>>>...
>>>assert(0);
>>>...
>>> }
>>>
>>>  if I run `ccall((:funcname, libpath), Void, (...), ...)` in Julia , it
>>>  will  terminate the Julia process.
>>>
>>> How can I replace assert() with other function to throw an error in
>>> Julia?
>>>
>>>
>>> > ccall((:funcname, libpath), Void, (...), ...)
>>>
>>> ERROR: 
>>>
>>> I am sorry that I can not make it clear, and I just come to Julia from
>>> the R world.
>>>
>>> Thanks.  ;-)
>>>
>>> I'm afraid I still don't get it. What do you want to do?


 On Dec 24, 2014, at 8:15 PM, 良无  wrote:

 If you want to release an R package to CRAN, R Core will force you to
 check this by R CMD check:

 - Compiled code should never terminate the R process within which it is
 running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and
 so on must be avoided. Nor may R code call q().


 Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit :
> > In my origin C++ code, I use assert(), but if I want to use this
> code
> > in Julia, maybe I need to replace it with other functions. In R, I
> can
> > use Rcpp::stop(). Is there any easy way to do it in Julia with C or
> C
> > ++ code.
> IIUC, you want to raise a Julia exception from C code, right?
>
> > And it seems that Julia does not have R CMD check like stuff yet. It
> > does not check this kind of issue.
> You mean, running a test suite? See
> http://docs.julialang.org/en/latest/stdlib/test/
>
> and how most packages do this, for example
> https://github.com/JuliaStats/StatsBase.jl/tree/master/test
>
>
> Regards
>

>>
>


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Stefan Karpinski
Isn't it the opposite of that though? I.e. catching C++ assert failures?

On Wed, Dec 24, 2014 at 11:46 PM, Isaiah Norton 
wrote:

> This might help:
>
> http://docs.julialang.org/en/release-0.3/manual/embedding/#throwing-julia-exceptions
>
> On Wed, Dec 24, 2014 at 10:41 PM, 良无  wrote:
>
>> In C or C++ code, I have a function:
>>
>> void funcname(...){
>>...
>>assert(0);
>>...
>> }
>>
>>  if I run `ccall((:funcname, libpath), Void, (...), ...)` in Julia , it
>>  will  terminate the Julia process.
>>
>> How can I replace assert() with other function to throw an error in Julia?
>>
>>
>> > ccall((:funcname, libpath), Void, (...), ...)
>>
>> ERROR: 
>>
>> I am sorry that I can not make it clear, and I just come to Julia from
>> the R world.
>>
>> Thanks.  ;-)
>>
>> I'm afraid I still don't get it. What do you want to do?
>>>
>>>
>>> On Dec 24, 2014, at 8:15 PM, 良无  wrote:
>>>
>>> If you want to release an R package to CRAN, R Core will force you to
>>> check this by R CMD check:
>>>
>>> - Compiled code should never terminate the R process within which it is
>>> running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and
>>> so on must be avoided. Nor may R code call q().
>>>
>>>
>>> Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit :
 > In my origin C++ code, I use assert(), but if I want to use this code
 > in Julia, maybe I need to replace it with other functions. In R, I
 can
 > use Rcpp::stop(). Is there any easy way to do it in Julia with C or C
 > ++ code.
 IIUC, you want to raise a Julia exception from C code, right?

 > And it seems that Julia does not have R CMD check like stuff yet. It
 > does not check this kind of issue.
 You mean, running a test suite? See
 http://docs.julialang.org/en/latest/stdlib/test/

 and how most packages do this, for example
 https://github.com/JuliaStats/StatsBase.jl/tree/master/test


 Regards

>>>
>


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Isaiah Norton
This might help:
http://docs.julialang.org/en/release-0.3/manual/embedding/#throwing-julia-exceptions

On Wed, Dec 24, 2014 at 10:41 PM, 良无  wrote:

> In C or C++ code, I have a function:
>
> void funcname(...){
>...
>assert(0);
>...
> }
>
>  if I run `ccall((:funcname, libpath), Void, (...), ...)` in Julia , it
>  will  terminate the Julia process.
>
> How can I replace assert() with other function to throw an error in Julia?
>
>
> > ccall((:funcname, libpath), Void, (...), ...)
>
> ERROR: 
>
> I am sorry that I can not make it clear, and I just come to Julia from the
> R world.
>
> Thanks.  ;-)
>
> I'm afraid I still don't get it. What do you want to do?
>>
>>
>> On Dec 24, 2014, at 8:15 PM, 良无  wrote:
>>
>> If you want to release an R package to CRAN, R Core will force you to
>> check this by R CMD check:
>>
>> - Compiled code should never terminate the R process within which it is
>> running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and
>> so on must be avoided. Nor may R code call q().
>>
>>
>> Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit :
>>> > In my origin C++ code, I use assert(), but if I want to use this code
>>> > in Julia, maybe I need to replace it with other functions. In R, I can
>>> > use Rcpp::stop(). Is there any easy way to do it in Julia with C or C
>>> > ++ code.
>>> IIUC, you want to raise a Julia exception from C code, right?
>>>
>>> > And it seems that Julia does not have R CMD check like stuff yet. It
>>> > does not check this kind of issue.
>>> You mean, running a test suite? See
>>> http://docs.julialang.org/en/latest/stdlib/test/
>>>
>>> and how most packages do this, for example
>>> https://github.com/JuliaStats/StatsBase.jl/tree/master/test
>>>
>>>
>>> Regards
>>>
>>


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Stefan Karpinski
Ah, I see. You want to trap assertion failures happening in C/C++ from
Julia. Thanks for clarifying.

On Wed, Dec 24, 2014 at 10:41 PM, 良无  wrote:

> In C or C++ code, I have a function:
>
> void funcname(...){
>...
>assert(0);
>...
> }
>
>  if I run `ccall((:funcname, libpath), Void, (...), ...)` in Julia , it
>  will  terminate the Julia process.
>
> How can I replace assert() with other function to throw an error in Julia?
>
>
> > ccall((:funcname, libpath), Void, (...), ...)
>
> ERROR: 
>
> I am sorry that I can not make it clear, and I just come to Julia from the
> R world.
>
> Thanks.  ;-)
>
> I'm afraid I still don't get it. What do you want to do?
>>
>>
>> On Dec 24, 2014, at 8:15 PM, 良无  wrote:
>>
>> If you want to release an R package to CRAN, R Core will force you to
>> check this by R CMD check:
>>
>> - Compiled code should never terminate the R process within which it is
>> running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and
>> so on must be avoided. Nor may R code call q().
>>
>>
>> Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit :
>>> > In my origin C++ code, I use assert(), but if I want to use this code
>>> > in Julia, maybe I need to replace it with other functions. In R, I can
>>> > use Rcpp::stop(). Is there any easy way to do it in Julia with C or C
>>> > ++ code.
>>> IIUC, you want to raise a Julia exception from C code, right?
>>>
>>> > And it seems that Julia does not have R CMD check like stuff yet. It
>>> > does not check this kind of issue.
>>> You mean, running a test suite? See
>>> http://docs.julialang.org/en/latest/stdlib/test/
>>>
>>> and how most packages do this, for example
>>> https://github.com/JuliaStats/StatsBase.jl/tree/master/test
>>>
>>>
>>> Regards
>>>
>>


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread 良无
In C or C++ code, I have a function:

void funcname(...){
   ...
   assert(0);
   ...
}

 if I run `ccall((:funcname, libpath), Void, (...), ...)` in Julia , it 
 will  terminate the Julia process.

How can I replace assert() with other function to throw an error in Julia?


> ccall((:funcname, libpath), Void, (...), ...)

ERROR: 

I am sorry that I can not make it clear, and I just come to Julia from the 
R world.  

Thanks.  ;-) 

I'm afraid I still don't get it. What do you want to do?
>
>
> On Dec 24, 2014, at 8:15 PM, 良无 > wrote:
>
> If you want to release an R package to CRAN, R Core will force you to 
> check this by R CMD check:
>
> - Compiled code should never terminate the R process within which it is 
> running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and 
> so on must be avoided. Nor may R code call q().
>
>
> Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit : 
>> > In my origin C++ code, I use assert(), but if I want to use this code 
>> > in Julia, maybe I need to replace it with other functions. In R, I can 
>> > use Rcpp::stop(). Is there any easy way to do it in Julia with C or C 
>> > ++ code. 
>> IIUC, you want to raise a Julia exception from C code, right? 
>>
>> > And it seems that Julia does not have R CMD check like stuff yet. It 
>> > does not check this kind of issue. 
>> You mean, running a test suite? See 
>> http://docs.julialang.org/en/latest/stdlib/test/ 
>>
>> and how most packages do this, for example 
>> https://github.com/JuliaStats/StatsBase.jl/tree/master/test 
>>
>>
>> Regards 
>>
>

Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Stefan Karpinski
I'm afraid I still don't get it. What do you want to do?


> On Dec 24, 2014, at 8:15 PM, 良无  wrote:
> 
> If you want to release an R package to CRAN, R Core will force you to check 
> this by R CMD check:
> 
> - Compiled code should never terminate the R process within which it is 
> running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and so 
> on must be avoided. Nor may R code call q().
> 
> 
>> Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit : 
>> > In my origin C++ code, I use assert(), but if I want to use this code 
>> > in Julia, maybe I need to replace it with other functions. In R, I can 
>> > use Rcpp::stop(). Is there any easy way to do it in Julia with C or C 
>> > ++ code. 
>> IIUC, you want to raise a Julia exception from C code, right? 
>> 
>> > And it seems that Julia does not have R CMD check like stuff yet. It 
>> > does not check this kind of issue. 
>> You mean, running a test suite? See 
>> http://docs.julialang.org/en/latest/stdlib/test/ 
>> 
>> and how most packages do this, for example 
>> https://github.com/JuliaStats/StatsBase.jl/tree/master/test 
>> 
>> 
>> Regards 


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread 良无
If you want to release an R package to CRAN, R Core will force you to check 
this by R CMD check:

- Compiled code should never terminate the R process within which it is 
running. Thus C/C++ calls to assert/abort/exit, Fortran calls to STOP and 
so on must be avoided. Nor may R code call q().


Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit : 
> > In my origin C++ code, I use assert(), but if I want to use this code 
> > in Julia, maybe I need to replace it with other functions. In R, I can 
> > use Rcpp::stop(). Is there any easy way to do it in Julia with C or C 
> > ++ code. 
> IIUC, you want to raise a Julia exception from C code, right? 
>
> > And it seems that Julia does not have R CMD check like stuff yet. It 
> > does not check this kind of issue. 
> You mean, running a test suite? See 
> http://docs.julialang.org/en/latest/stdlib/test/ 
>
> and how most packages do this, for example 
> https://github.com/JuliaStats/StatsBase.jl/tree/master/test 
>
>
> Regards 
>


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Milan Bouchet-Valat
Le mercredi 24 décembre 2014 à 08:36 -0800, 良无 a écrit :
> In my origin C++ code, I use assert(), but if I want to use this code
> in Julia, maybe I need to replace it with other functions. In R, I can
> use Rcpp::stop(). Is there any easy way to do it in Julia with C or C
> ++ code.
IIUC, you want to raise a Julia exception from C code, right?

> And it seems that Julia does not have R CMD check like stuff yet. It
> does not check this kind of issue.
You mean, running a test suite? See
http://docs.julialang.org/en/latest/stdlib/test/

and how most packages do this, for example
https://github.com/JuliaStats/StatsBase.jl/tree/master/test


Regards


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Stefan Karpinski
Also, please don't double post here and on stack overflow:

http://stackoverflow.com/questions/27639720/can-i-throw-an-error-in-c-code-just-like-rcpps-stop-in-julia

It's the same people answering in both places. Once you get an answer in
one place, please cross link so that the answer appears in both places –
that's what we end up having to do when people double post their questions
like this.

On Wed, Dec 24, 2014 at 12:06 PM, Stefan Karpinski 
wrote:

> Since I have no idea what Rcpp::stop() or R CMD check do, it's hard to
> answer this question. Can you explain what you want to accomplish?
>
> On Wed, Dec 24, 2014 at 11:36 AM, 良无  wrote:
>
>> In my origin C++ code, I use assert(), but if I want to use this code in
>> Julia, maybe I need to replace it with other functions. In R, I can use
>> Rcpp::stop(). Is there any easy way to do it in Julia with C or C++ code.
>>
>> And it seems that Julia does not have R CMD check like stuff yet. It
>> does not check this kind of issue.
>>
>> Thanks.
>>
>
>


Re: [julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread Stefan Karpinski
Since I have no idea what Rcpp::stop() or R CMD check do, it's hard to
answer this question. Can you explain what you want to accomplish?

On Wed, Dec 24, 2014 at 11:36 AM, 良无  wrote:

> In my origin C++ code, I use assert(), but if I want to use this code in
> Julia, maybe I need to replace it with other functions. In R, I can use
> Rcpp::stop(). Is there any easy way to do it in Julia with C or C++ code.
>
> And it seems that Julia does not have R CMD check like stuff yet. It does
> not check this kind of issue.
>
> Thanks.
>


[julia-users] Can I throw an error in c code just like Rcpp's stop() in Julia

2014-12-24 Thread 良无


In my origin C++ code, I use assert(), but if I want to use this code in 
Julia, maybe I need to replace it with other functions. In R, I can use 
Rcpp::stop(). Is there any easy way to do it in Julia with C or C++ code.

And it seems that Julia does not have R CMD check like stuff yet. It does 
not check this kind of issue.

Thanks.