<flux>
I guess -unsafe is an easy way to find out if using those unsafe functions are worth it in the first place
nicholasf has quit [Remote host closed the connection]
<adrien>
you can also see it in the profiling
<adrien>
iirc the bound checks appear there
nicholasf has joined #ocaml
<adrien>
and since you should start with profiling anyway :)
<lalaalalalalla>
@flux, I am very new to the language, did you mean we'd better not use unsafe at all? My intention is simply to follow through the tutorial and see what I can learn.
<adrien>
unless your code is very array-intensive, it's unlikely you'll get much by removing array bound checks
<adrien>
and from a safety perspective that means trading safety (out of bounds are reported as exceptions) for some performance
<adrien>
not the kind of tradeoff that is typically done in ocaml (well, sometimes, yes, but usually people try hard to get better performance without trading safety)
<flux>
lalaalalalalla, I think it's not worth using the unsafe features unless you can pin-point that they could bring noticeable performance benefits
<flux>
I mean, would you rather have an exception or random memory corruption in your ocaml program?
<flux>
most optimistic case is getting a segmentation fault, but that's not guaranteed at all
<flux>
maybe if you're writing a matrix library or do image processing are the unsafe functions worth it
kakadu has joined #ocaml
<lalaalalalalla>
I think I basically got the idea. So now I am just curious maybe the tutorial article is outdated? or there is something different than I did for the simple -unsafe usage mentioned in the article.
pierpa has joined #ocaml
<lalaalalalalla>
the test is simply to compile the following line with "ocamlopt -unsafe" -- "let a = Array.make 10 0.0
<lalaalalalalla>
for i = 0 to 9 do a.(i) <- float_of_int i; done;;
<flux>
so how do yo determine if -unsafe is not in effect?
<flux>
if you want to find it out, you could just change the upper bound of the loop from 9 to 10
<flux>
with -unsafe it will not raise an exception
<lalaalalalalla>
oh right, it told me Error : Unbound module array. and generated nothing.
<ggole>
...
<flux>
so I guess it fails same way with or withot -unsafe?-)
<lalaalalalalla>
yes, failed in both ways.
<flux>
seems like you have written array.make in your actual source code, not Array.make
Algebr` has joined #ocaml
<flux>
hmm, or not
<flux>
if Array.make doesn't work, your compiler installation is somehow broken
<lalaalalalalla>
I double checked. it is Array instead of array.
orbifx1 has joined #ocaml
<flux>
all in all, the problem is completely unrelated to -unsafe :)
<lalaalalalalla>
Is there any other way to test it?
<ggole>
You'll need a working program first.
<lalaalalalalla>
I installed ocaml by using opam-installer.sh then opam swith 4.03 on archlinux.
octachron has joined #ocaml
<flux>
did you also do eval $(opam config env) after that?
<lalaalalalalla>
I can compile other simple code so far. for example just the binary tree on the ocaml website main page.
<lalaalalalalla>
yes and I have been using this version for several weeks.
<flux>
so if you start ocaml shell, what does #show Array;; do?
<octachron>
lalaalalalalla, is your test file called array?
<lalaalalalalla>
Error: Unbound value show.
<ggole>
Include the #.
<ggole>
That is, #show and not show.
<lalaalalalalla>
well. @ggole, it outputs a lot things...
<flux>
well, it seems the Array module exists fine in your ocaml then.
<ggole>
That's the Array module
<flux>
so if you put this into foo.ml: let _ = Array.make 10
<flux>
and then ocamlopt foo.ml
<flux>
does it give you an error?
<lalaalalalalla>
@octachron, I rename my array.ml to test.ml and now it is working with -unsafe flag on.
<flux>
the key is that your module name (Array) is conflicting with the existing system module Array
<lalaalalalalla>
haha, I did not know this. really good to know. Thanks all of you!
octachron has quit [Quit: Leaving]
<flux>
happy hacking :)
lalaalalalalla has left #ocaml [#ocaml]
Nahra has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
zpe has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
<Algebr`>
bucklescript for the future!
johnelse has joined #ocaml
johnelse has quit [Ping timeout: 240 seconds]
Nahra has joined #ocaml
<jstolarek>
how do I load a source file into utop?
<Algebr`>
#use
<Algebr`>
#use "foo.ml";;
<jstolarek>
thanks
<ggole>
#mod_use is also useful
silver has joined #ocaml
<jstolarek>
where can I find the list of all commands available in utop?
<jstolarek>
a list with description of each command that is
<Algebr`>
jstolarek: like the builtin ones using #?
<Algebr`>
as a first approx, you could do # and then tab
<jstolarek>
Algebr`: but that does not give me any description of what each command does
tristero has quit [Quit: tristero]
<jstolarek>
for example, what is the difference between #mod and #use_mod ?
<Algebr`>
yes, good point. I don't remember where's the docs for it. Probably check on github README for utop?
MercurialAlchemi has quit [Ping timeout: 250 seconds]
Intensity has quit [Ping timeout: 240 seconds]
Intensity has joined #ocaml
zpe has joined #ocaml
nicholasf has joined #ocaml
kakadu has quit [Remote host closed the connection]
zpe has quit [Ping timeout: 258 seconds]
dwwoelfe_ has joined #ocaml
sh0t has quit [Ping timeout: 244 seconds]
dwwoelfel has quit [Ping timeout: 244 seconds]
silver has quit [Ping timeout: 244 seconds]
ollehar has joined #ocaml
<ollehar>
an honest question: if I make a compiler that compiles down to malfunction, couldn't I just as well compile down to (a subset of) ocaml itself? what would the benefit be of using malfunction (or compiling down to an IR of ocaml instead of ocaml)?
<Drup>
you don't have to bother with pleasing the typechecker
<Drup>
depending on your language, that might be a really big gain
<ollehar>
hm
silver has joined #ocaml
<Drup>
also, while it might be true that for any code you may want to emit, there is a corresponding ocaml program, that program might be neither pleasant nor easy to find
<ollehar>
well in my case, compiling statically typed php, I'm not sure.
sh0t has joined #ocaml
<ollehar>
I guess I could just make a list of the correspondence.
<ollehar>
php-to-ocaml transpiler ><
<ollehar>
heh
d0nn1e has quit [Ping timeout: 244 seconds]
d0nn1e has joined #ocaml
ollehar has quit [Quit: ollehar]
strykerkkd has quit [Remote host closed the connection]