User Tools

Site Tools


juliaism

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

juliaism [2018/08/21 14:17] (current)
Line 1: Line 1:
 +
 +~~CLOSETOC~~
 +
 +~~TOC 1-3 wide~~
 +
 +
 +quick and unimportant question: What is the proper julia-ism for a custom error message incorporating the C system error, like perl'​s?​
 +
 +```perl
 +open(my $f, "<​$filename"​) or warn "my error message: $!\n"
 +```
 +
 +is it
 +
 +```
 +try
 +    f= open(filename)
 +catch
 +    warn("​my error message $(Libc.strerror(Libc.errno()))"​)
 +end
 +```
 +
 +if so, perl's `$!` encourages more use than `$(Libc.strerror(Libc.errno()))`. ​ It's a minor nuisance, because most of the time, one uses "​die"​ instead of "​warn,"​ and unlike perl, julia throws an informative error by itself, albeit non-customizable. ​ it's enough 99% of the time.
 +
 +
  
juliaism.txt ยท Last modified: 2018/08/21 14:17 (external edit)