<dsheets>
could you run with line 305 to tell also the number of words? is it greater than 3?
<m4b>
one second: alternatively, here are the array version implementation of those functions: dpaste.com/901328/
<m4b>
dsheets: also, thank you for looking into this, regardless of the outcome, I appreciate you taking your time very much :)
hongboz has joined #ocaml
<m4b>
there are 5 mallocs on the same address, with words: 3 5 3 5 3, respectively
<dsheets>
m4b: what does "offset" mean? if you malloc'd 3 words but then use "offset" on line 319 to index, shouldn't you subtract 1?
<dsheets>
i mean, it makes sense if it's really an offset… but clearly you can't get an offset of 3 into a block of 3 whose largest offset is 2, no? am i missing something?
<m4b>
offsets start at 0; there are several other binaries, squaring, factorial, etc., which all run fine with the hashtable and array version; but those are smaller programs, and less allocing and deallocing is occuring
darkf has joined #ocaml
<m4b>
index array problems occurred earlier in the implementation when it wasn't quite implemented right; since they are working with the other problems fine, and I get no cases of out of bounds there, and in this case it is clearly when the address was mallocd, then dealloced, etc., that a problem occurred, and hence I suspect the hash tables
leoncamel has joined #ocaml
<dsheets>
hmm… but it seems like an off-by-one problem, no? if the last malloc was for 3 words and then you want the word at offset 3… that's a fault, right?
<dsheets>
are you sure the array version is not incorrectly passing a buggy program?
<m4b>
i agree; however the off-by-one problem would definitely have occurred in a previous problem, square, if it was the issue; i've looked through that assembly for quite some time, and there are many cases where if the index isn't implemented right, it's an off-by-one; notice however, the previous malloc had 5 words
<m4b>
i have independent verification that the program runs on a vm implemented in haskell; i do have high hopes however if I can get the hashtable version running, it will be faster :D
<m4b>
i'm going to put the same printfs in the array version, and see if the execution is running in parallel; if not, then the issue is deeper, and probably a small bug somewhere else affecting the execution
<dsheets>
indeed. i'm not sure the trouble is with the hashtbls, though. doing a.(3) on an array a with length 3 should fail
<m4b>
yes, it should
leoncamel has quit [Ping timeout: 260 seconds]
<dsheets>
and from the debug output, that seems to be the case
<hongboz>
hi guys, would you mind sharing your experience when you meet segfault in ocaml?
<m4b>
dsheets: i know its tempting to think its an off-by-one, but I assure you, it isn't a dereferencing problem; the aidx and aupd pattern matching is _exactly_ the same for both versions; for the update function, since the same offset is passed in and used to dereference that array's value at that offset, it simply can't be the problem with aidx and aupd instructions being misimplemented; it has to be the hash table, or it has to be a
<m4b>
deeper program logic flaw.
travisbrady has quit [Quit: travisbrady]
emmanuelux has quit [Remote host closed the connection]
<dsheets>
m4b: right. your debug output seems to indicate that an array of length 3 should exist at hashtbl location 346 and your machine fault indicates that the offset into the page at 346 should be 3… these can't be true while the input program is bug-free. Can you instrument your other interpreters to tell you more info about their behavior in this exact spot?
<m4b>
dsheets: yes, that is a correct analysis. so the program executions diverge after dealloc 661; the array version then mallocs 662; the hashtable version mallocs 661, both with two words; the hashtable then deallocs 661, while the array deallocs 662; not sure what to make of that...
tac has joined #ocaml
<m4b>
does Hashtbl.length count the invisible elements?
<dsheets>
invisible? Hashtbl.length counts the number of values (which may be fewer than keys)
<dsheets>
rather… greater than keys
<dsheets>
anyway, use replace and they will be equal
<m4b>
so since one version calculates the new address using Hashtbl.length and returns that value as the new address, whereas the other calculates it by Array.length and returns that value, they'll eventually return different values, correct?
<m4b>
the hashtable version with all that output uses replace; add isn't present anywhere, except when initializing the program
<dsheets>
yes, so i believe that length should be the same
<m4b>
yes, actually that output makes sense; the array version wastes space by replacing dealloc'd arrays with FREE; whereas the hashtable actually reuses the space
<dsheets>
you keep no free-list
yacks has joined #ocaml
<dsheets>
and newAddress will be wrong a lot in the Hashtbl version
<dsheets>
because you always expect a fresh address but then get back a used address
<dsheets>
so, keep a free-list?
<dsheets>
or dealloc by replacing by [||] instead of removing?
derek_c has joined #ocaml
<m4b>
oh! I think i may see what you're saying; the length version returns the size of the hashtable; but it just might happen that that same number was given before, the table was then expanded, then shrunk again with deallocs, and the same size is encountered, and so the number is given. Damn! that might be it right there! However, deallocing with [||] undesirable for the reason that it is just wasting memory; and memory becoming a huge
<m4b>
problem; the 15 meg binary is using about 1.5-2 gigs of ram when executing.
<dsheets>
does it match your machine model? [||] wastes 1 hash table entry and 1 gc block
<dsheets>
i believe deallocing with [||] is the model that is implemented with arrays and FREE
<m4b>
it is what is implemented with the arrays and FREE; but that specifically isn't required by the machine; all that is required by the assembly instruction "malloc 2 5", for example, is: allocate an array with the number of words found in register 5, and put the _unique_ identifier in register 2
<m4b>
but I think what you've made me realize is my newAddress function for hashtables isn't guaranteeing a unique identifier!
<dsheets>
yes. use a free list if having [||] table entries bothers you. when dealloc, push onto the free list. when alloc, pop.
<m4b>
i'm unfamiliar with what a free list is?
<dsheets>
m4b: a list tracking free memory
<dsheets>
i think in your case: free_list : int list
<m4b>
dsheets: ok, right; i'll implement that for a correct version; right now just using a stupid brute force recursive function to actually check if that's the problem :D
* dsheets
wanders away
yroeht has quit [Ping timeout: 252 seconds]
yroeht has joined #ocaml
ulfdoz_ has joined #ocaml
<m4b>
dsheets: that was it :D thank you so much for troubleshooting a problem that turned out to be nothing related to the map module :DDD
travisbrady has joined #ocaml
ulfdoz has quit [Ping timeout: 248 seconds]
ulfdoz_ is now known as ulfdoz
<travisbrady>
I'm looking to wrap this library: https://github.com/edenhill/librdkafka but it uses pthreads. Will I need to do anything special to handle that?
madroach has quit [Ping timeout: 248 seconds]
madroach has joined #ocaml
<m4b>
dsheets: take care, have a good night/morning/afternoon, and again, I appreciate the help!
m4b has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
tac has quit [Ping timeout: 245 seconds]
silkwood has joined #ocaml
mcsquiggedy has quit [Quit: Leaving]
hongboz has quit [Read error: Connection reset by peer]
hongboz has joined #ocaml
travisbrady has quit [Quit: travisbrady]
yacks has quit [Remote host closed the connection]
<derek_c>
('a -> 'a -> 'b) -> 'a -> ('a -> 'b) * 'b
<derek_c>
can anyone think of an expression that will result in a type like that?
<derek_c>
I don't understand how to get ('a -> 'a -> 'b)
<derek_c>
that should be a function right?
darkf has quit [Read error: Connection reset by peer]
<derek_c>
in general, I just wonder how you can possibly get a function like ('a -> 'b)?
<derek_c>
let f x = ?
darkf has joined #ocaml
<PM>
derek_c: a function that raise an exception (like fun a -> failwith "") is of type 'a -> 'b
<derek_c>
PM: Is that the only way?
silkwood has quit [Quit: Ex-Chat]
<PM>
… or a function that never ends :-) like let rec f x = f x
<PM>
derek_c: I don’t known another way to do it, but there may be more
<derek_c>
hmm, that really helps!
<derek_c>
so how about ('a -> 'a -> 'b)?
<derek_c>
if I do:
<derek_c>
let x = fun y -> something
<derek_c>
that will be ('a -> 'b -> something)
<PM>
what is your use case? I’m curious
<derek_c>
no, that's just a homework question
<PM>
I see ;-)
<derek_c>
we need to come up with expressions that result in the specified type
<PM>
alright, then: how could you make the type inference assure that x and y are of the same type in: let x y = failwith "nonsense"?
<derek_c>
give me a sec
<derek_c>
hmm, I'm trying to do this:
<derek_c>
let x y = let q = [x; y] in failwith "dwadaw";;
<derek_c>
but it's ('a -> 'b) -> 'c
<derek_c>
I thought if I put two things in a list
<derek_c>
they will be of the same type
<PM>
they should actually
<PM>
it works on my machine
<derek_c>
wait really??
<PM>
# let f x y = let _ = [x;y] in failwith "";;
<derek_c>
oh I see
<PM>
val f : 'a -> 'a -> 'b = <fun>
<PM>
ah, you made a typo ;)
<derek_c>
lol
<derek_c>
yeah, and I defined x earlier
<derek_c>
I missed the f
<derek_c>
hmm cool, let me if I can solve this problem then
hongboz has quit [Ping timeout: 248 seconds]
<derek_c>
OMG this is so hard
<derek_c>
let f2 = (fun x -> failwith "whatever", failwith "whatever");;
<derek_c>
I'm expecting ('a -> 'b) * 'b
<derek_c>
but this results in 'a -> 'b * 'c
<PM>
can you see why?
ttamttam has joined #ocaml
cyball has quit [Ping timeout: 245 seconds]
andreypopp has joined #ocaml
ttamttam has quit [Remote host closed the connection]
dabd_ has joined #ocaml
Cyanure has joined #ocaml
<derek_c>
not really... unless failwith doesn't return the same type each time
<PM>
that’s the meaning of 'b in 'a -> 'b
<PM>
plus: (fun x -> x, x) => fun x -> (x, x) ("," has a higher priority than "->", that’s basically a parsing issue)
mcclurmc has joined #ocaml
<derek_c>
PM: thank you, I will think about this
clog has joined #ocaml
andreypopp has joined #ocaml
mika1 has joined #ocaml
adotbrown has joined #ocaml
ftrvxmtrx_ has joined #ocaml
andreypopp has quit [Read error: Connection reset by peer]
adotbrown has quit [Ping timeout: 248 seconds]
andreypopp has joined #ocaml
djcoin has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
cdidd has quit [Remote host closed the connection]
andreypopp has quit [Read error: Connection reset by peer]
<rixed>
Someone managed to get BER N100 up and running?
derek_c has quit [Quit: Lost terminal]
f[x] has quit [Remote host closed the connection]
f[x] has joined #ocaml
mcclurmc has joined #ocaml
\rs has quit [Ping timeout: 264 seconds]
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
SanderM has joined #ocaml
xaimus has quit [Ping timeout: 255 seconds]
xaimus has joined #ocaml
cyball has joined #ocaml
\rs has joined #ocaml
andreypopp has joined #ocaml
PM has quit [Remote host closed the connection]
PM has joined #ocaml
_andre has joined #ocaml
rixed has quit [Quit: umount home]
thomasga has joined #ocaml
rixed has joined #ocaml
protz has joined #ocaml
Cyanure has joined #ocaml
<protz>
how can I distribute a cmxs file with ocamlfind? i.e. what do I put in my META file?
<protz>
there are no examples on the ocamlfind website
Submarine has quit [Remote host closed the connection]
<protz>
just a BNF grammar for META files, and looking at other packages, none of them seems to distribute cmxs files
<pippijn>
hmm
<pippijn>
oasis adds the line you need
<pippijn>
it has "plugin" in it
<protz>
not interested in oasis, thanks :)
<pippijn>
are you stupid?
<pippijn>
> it adds the line you need
<pippijn>
so using it to create a hello world project will teach you what line you need to add
ocp has joined #ocaml
<pippijn>
(oasis 0.3+ by the way)
<adrien_oww>
I'm not sure cmxs file smake a lot of sense in META files
<adrien_oww>
could be wrong
<pippijn>
adrien_oww: cmxs are plugins, no?
<adrien_oww>
yes
cyball has quit [Ping timeout: 248 seconds]
<pippijn>
what's that web server called again?
<pippijn>
ocsigen
<pippijn>
that one can use cmxs from META, I think
<pippijn>
the oasis changelog mentioned it when giving the reason for this change
<protz>
adrien: thanks, I realize I confused cmxs and cmx
<pippijn>
oh
<protz>
adrien: it's the cmx I want to distribute along with the cma and the cmxa
<pippijn>
why?
<pippijn>
the cmx are inside the cmxa
<protz>
pippijn: to enable cross-module optimizations in native code?
<pippijn>
aren't they?
<protz>
I thought they were *not* in the cmxa?
<pippijn>
hmm
<pippijn>
I'm pretty sure they are, because I seem to remember problems caused by it
<protz>
pippijn: correct, I just checked the reference manual
<protz>
thanks!
Yoric has quit [Ping timeout: 246 seconds]
<pippijn>
either way, cmx files definitely don't go into the META file
mye_ has joined #ocaml
<mfp>
pippijn> the cmx are inside the cmxa -> ??? I thought cross-module inlining only happened when you had the .cmx around
<protz>
mfp: I thought too...
<mfp>
protz: what did you find in the reference manual? (protz> pippijn: correct, I just checked the reference manual)
<protz>
mfp: Such a library packs in two files (lib.cmxa and lib.a/.lib) a set of object files (.cmx and .o/.obj files).
<thomasga>
if you have a cmxa the cmx files are optionals
mye has quit [Ping timeout: 255 seconds]
mye_ is now known as mye
<thomasga>
if they are in the path, they are used
<thomasga>
otherwise, the compiler doens't care
<pippijn>
thomasga: are they useful?
<thomasga>
for cross-module inlining yes
<thomasga>
ie. if you want improved performance
<pippijn>
ok
<thomasga>
otherwise not really
<protz>
thomasga: what I did is I'm not mentioning them in the META file but I'm installing them through the call to ocamlfind install
<pippijn>
then I guess I remember incorrectly
<protz>
which solves my problem
<thomasga>
protz: that's indeed the right way to go
<protz>
thomasga: so in my case I'm building the .cma and the .cmxa (it's a library); does that mean I should install other the other cmx from all the other individual files that make up the big cmxa ?
<protz>
because ocamlbuild mylib.cmxa yields nothing
<thomasga>
you can install the cmx if you want cross-module optimizations
<thomasga>
if you don't install the cmx files, this will still works
<protz>
thomasga: which cmx? I can't find out how to build mylib.cmx
Snark has joined #ocaml
<thomasga>
not for the lib itself
<protz>
thomasga: thanks, that answers my question :)
<thomasga>
for the modules in the lib
logicgeezer_ has quit [Read error: Connection reset by peer]
thelema_ has joined #ocaml
thelema has quit [Read error: Operation timed out]
gour has quit [Disconnected by services]
gour_ has joined #ocaml
jonafan has quit [Read error: Operation timed out]
<osa1>
do we have a funciton like Printf.printf but to generate interpolated strings ?
<osa1>
or can I print to some kind of string streams ?
<PM>
osa1: are you looking for Printf.sprintf ?
<osa1>
yes, thanks
skow has joined #ocaml
<skow>
Hai guys,a question - what does it this mean -> arrays and lists are isomorphic data structure
<skow>
don't understand the meaning of isomorphic
<skow>
in this context I mean
<skow>
do they just mean, they are the same - nothing more?
<Kakadu>
I think it is just mathemetical `isomorphic`
<skow>
ok
<skow>
thanks
ahokaomaeha has quit [Ping timeout: 245 seconds]
ahokaomaeha has joined #ocaml
andreypopp has joined #ocaml
leoncamel has joined #ocaml
<nicoo>
skow: It is probably false, though : there are infinite lists; there is no infinite array
<chattered>
What's the context? It doesn't immediately sound like a particularly useful statement to make, anyway.
RagingDave has joined #ocaml
q66 has joined #ocaml
andreypopp has quit [Quit: sleep]
andreypopp has joined #ocaml
andreypopp has quit [Client Quit]
andreypopp has joined #ocaml
gnuvince has quit [Ping timeout: 252 seconds]
chambart has joined #ocaml
<orbitz>
anyone know when CUFP for 2013 will have info up? what is last call for presentations nad all
groovy2shoes has joined #ocaml
groovy2shoes has quit [Quit: Computer has gone to sleep]
<troydm>
orbitz: CUFP 2012 videos that i've seen were not of the best quality
<troydm>
i hope they will make up for it in this year
<troydm>
no wait my bad
<troydm>
i've mixed up Ocaml meetings vids with CUFP
<troydm>
CUFP's vids are indeed good
<troydm>
but Ocaml meetings vids are meh :(
<avsm>
sorry. really depends on the local arrangements
<avsm>
orbitz: the call for proposals should be out soon; you have a few months
thelema has joined #ocaml
thelema_ has quit [Read error: Connection reset by peer]
darkf has quit [Quit: Leaving]
<skow>
hi guys, I wonder where does hd::tl in: let test arg = match arg with hd::tl -> tl;; come from...
<ben_zen>
skow: it's a pattern; if arg is a list containing at least one element, it has the form hd::tl, where hd is the first element in the list, and tl is the rest.
<skow>
ben_zen, when can I fnd the list of patterns available?
<ben_zen>
skow: there are as many patterns available as there are constructs you can make in the language.
<skow>
ah, ok
<ben_zen>
They tend to fall along the lines of specific values (0, 1, 2, 'a', 'b', ...)
<ben_zen>
or ways the data is arranged (hd::tl, [], (a, b, c, d))
<ben_zen>
or as variants of a type.
<skow>
ok, thanks!
jamii has joined #ocaml
cdidd has joined #ocaml
travisbrady has joined #ocaml
smondet has joined #ocaml
osa1 has quit [Ping timeout: 245 seconds]
dezzy has quit [Quit: Changing server]
Kakadu has quit []
dezzy has joined #ocaml
dezzy has quit [Changing host]
dezzy has joined #ocaml
<orbitz>
avsm: great, thanks
<orbitz>
trying to find something I can talk about so my work will pay for me to go :)
<invariant>
What can I do about this? Fatal error: cannot load shared library dlllwt-unix_stubs
<invariant>
This happens when executing 4.00.1/bin/utop
<thelema>
invariant: sounds like your ld.conf file doesn't have the path to where lwt's stubs were installed
<invariant>
thelema, but I did the eval opam config dance.
<avsm>
you're using OPAM from git, aren't you?
<avsm>
there was a small window where the CAML_LD_LIBRARY_PATH was broken a few days ago
<avsm>
if you update to the latest, it'll work
<invariant>
avsm, yes, that works.
<invariant>
How nice is it to update and recompile opam in 2 minutes :)
<invariant>
Or 10 keystrokes to test.
<invariant>
Is there some Money type in OCaml too?
<invariant>
By OCaml, I mean anywhere on the Internet.
<thelema>
invariant: int
<invariant>
thelema, that doesn't even cover overflow.
<thelema>
Int64.t
Xizor has joined #ocaml
<invariant>
thelema, does that cover overflow?
Xizor has quit [Client Quit]
cago has joined #ocaml
<thelema>
invariant: yes, in that it can't overflow with all the money in the world
<thelema>
Batteries has a Int.Safe_int module that errors on overflow
<thelema>
no Int64.Safe_int; so only very large safe ints on 64-bit platforms
<invariant>
thelema, the advantage of overflow would be that it would be an extra safety net to make sure nothing "weird" is going on.
<thelema>
yes, yes.
<djcoin>
What are the technics in other languages to prevent/raise integer overflow errors ?
<thelema>
djcoin: Ada has this built into the language standard, and it's up to the compiler authors to implement it efficiently
andreypopp has quit [Quit: sleep]
<PM>
djcoin: python has abritrary precision integer arithmetic… and thus prevents integer overflow/underflow
<thelema>
some languages promote to a larger int type
yacks has quit [Quit: Leaving]
<djcoin>
yeah, promoting ? I hope you don't play with bits mask or something then
<thelema>
these are usually languages that don't demand super performance
<thelema>
djcoin: promoting requires some sort of dynamic dispatch of (+)
<companion_cube>
you can use Num in ocaml
<djcoin>
And at the deepest level, I guess you can't avoid an overflow detection after or before each operation I guess ?
<thelema>
djcoin: correct. there's flags that can be checked on x86, but there's still a test + branch required
<thelema>
although branch prediction will eliminate much of the cost of this
<thelema>
assuming you're not overflowing often
<djcoin>
Ah yeah, the flag is always set up of course, right. Yeah, so it does not cost so much. I'm not really aware of branch prediction behaviour, is it just a way of saying to the compiler "most of the time there won't be any overflow so optimize this branch" (I mean static prediction) ?
<djcoin>
yeah
<thelema>
what would the compiler do in that case? It still has to emit the branch
<thelema>
err, ignore
<thelema>
branch prediction is something that the CPU does.
<djcoin>
Well, I know there are instructions for gcc to make him prefer one branch other the other
<djcoin>
I guess it saves a "jmp" isntruction
<djcoin>
at the assembly level
<thelema>
looking at how often each branch of a test is taken, it can speculatively execute the more common one
<djcoin>
s/other the other/over the other
<thelema>
before the result of the test is known
<thelema>
if it's right, then it sped things up, if it was wrong, it has to throw away the work it just did and restart with the other branch