<wmeyer>
why you are allocating like this: value *args = new value[4];
<wmeyer>
instead of allocating Caml block?
<wmeyer>
as I said, you can't do this
<Kakadu>
and what is correct code?
derek_c has quit [Quit: Lost terminal]
<wmeyer>
In general Kakadu treat Caml heap as something special, understand the principles of GC
<wmeyer>
I'd just allocate with caml_alloc instead of new
<ggole>
Kakadu: the GC needs to be able to reach all caml values to relocate correctly
<ggole>
It doesn't know about new
<wmeyer>
ggole: perfect explanation!
<wmeyer>
in general you can always store C++ pointer to memory inside caml heap, but never other way round
<ggole>
A live C++ pointer
<ggole>
Deallocated ones can be reallocated as part of the caml heap, confusing the GC and leading to suffering.
<wmeyer>
not nesercairly, just something that resemebles address and it's outside the caml heap
<ggole>
Oh yeah, you can point at statically allocated stuff just fine
<wmeyer>
having a danling pointer is perfectly fine, if you know what you do
<ggole>
If you are in control of the deallocation?
<wmeyer>
yes
<ggole>
Yeah, makes sense
<wmeyer>
gc will not try to enter these pointers
<Kakadu>
okay. I should write `value args=caml_alloc(N,..);` and use it like `caml_callbackN(_meth,N,&args)`?
nimred has joined #ocaml
nimred has quit [Changing host]
nimred has joined #ocaml
<ggole>
No
<ggole>
Because then args can't be seen by the GC
<Kakadu>
sorry
<ggole>
Anytime a caml value is not visible to the caml runtime is a bug
<wmeyer>
you should not dereference values with ampersand
<Kakadu>
CAMLlocalN(args,...) and without `value`
<ggole>
Kakadu: there's a page in the ocaml docs about interfacing with C that explains the issues
<Kakadu>
ggole: I know.
<wmeyer>
I think getting that right takes time Kakadu. Please read about gc
<wmeyer>
really understanding the FFI issues is not a trivial problem. Either you learn by heart the rules in the pointed out by ggole document or just know what not to do.
Nahra has joined #ocaml
<Kakadu>
wmeyer: OCaml GC or general GC?
<ggole>
Most GC interfaces have similar rules
<wmeyer>
read about generational garbage collectors, it's always better to know more
<wmeyer>
it really helps!
<wmeyer>
ggole is right that most of these issues have common denominator, however, most of the that's called dynamic languages avoid most of these using reference counted objects
<wmeyer>
surely OCaml has far better runtime, therefore different set of rules apply
* Kakadu
thinks that he has knowledge but he can't appy them
<Kakadu>
apply*
<wmeyer>
I think the most important facts
<wmeyer>
- gc needs to reach every block
<wmeyer>
- the gc can move values during allocation and get rid of them
<wmeyer>
- the C stack frame may contain values
<wmeyer>
- you can store C pointers inside blocks
Yoric has joined #ocaml
<wmeyer>
- everything is either int or pointer to block
<wmeyer>
that's pretty much it
<ggole>
Kakadu: looking at your code, you also need to use the caml accessors instead of C's []
<ollehar>
I think I've misunderstod the user of opam switch... 4.00.1 in on terminal, 3.12.1 in another
eikke has joined #ocaml
<orbitz>
ollehar: did the other terminal do the config eval?
<ollehar>
nope
<orbitz>
well there you go
contempt has quit [Remote host closed the connection]
<wmeyer>
briefly, looks good Kakadu
<wmeyer>
orbitz: hello
<orbitz>
wmeyer: hai
contempt has joined #ocaml
<ollehar>
orbitz: can I upgrade the compiler permanently?
<ollehar>
not using opam
<Kakadu>
now I'm thinking why everything crashes. Possible reason is that OCaml value was moved by GC but compactions are disabled and that should not been happened
<orbitz>
ollehar: sure, install a new compiler not through opam
<ggole>
Kakadu: value args[4] = { _camlobj,_cca0,_cca1,_cca2 }; <- broken. Use CAMLlocalN.
wmeyer has quit [Remote host closed the connection]
<Kakadu>
ggole: and what should I write instead of `caml_callbackN(_meth, 4, args);` than?
<ggole>
That bit is fine, I think
eikke has quit [Ping timeout: 264 seconds]
<Kakadu>
Than I don't understand. Do u want `args` to be an OCaml array?
<ggole>
No. CAMLlocalN informs the GC about a C array of N values.
<ggole>
Which is what you need to do.
<Kakadu>
aaaah
<Kakadu>
I was thought that CAMLlocalN is pattern for CAMLlocal1..CAMLloca5 :)
<ggole>
Nope.
<ggole>
You really should read the page on interfacing with C again, it contains all the details.
<Kakadu>
#define CAMLlocalN(x, size) \
<Kakadu>
value x [(size)] = { 0, /* 0, 0, ... */ }; \
<ggole>
Even if it's boring.
<Kakadu>
CAMLxparamN (x, (size))
mikurubeam has quit [Read error: Connection reset by peer]
<Kakadu>
Okay, It is not exactly what I written
<ggole>
Excuse, me, my pasta is almost done. :)
* ggole
back in a bit
wmeyer has joined #ocaml
<ollehar>
"error loading shared library: dllpcre_stubs.so" no such file
<ollehar>
how do I check where it's looking?
<ollehar>
the compiler, I mean
<orbitz>
ocamlc might have an option to print search path
<wmeyer>
CAML_LD_LIBRARY_PATH is the interesting variable
<orbitz>
otherwise strace can tell you
<orbitz>
also: is pcre isntalled via opam? if so you have to do the eval
<wmeyer>
you can do: ls -l ~/.opam/**/dllpcre_stubs.so
<wmeyer>
sometimes I had such problems (not pointing to the location for the bytecode runtime shared libs)
<wmeyer>
I don't remember if that was misconfiguration or something else
<Kakadu>
for me it is in /home/kakadu/.opam/4.00.1/lib/stublibs/dllpcre_stubs.so
mikurubeam has joined #ocaml
ttamttam has joined #ocaml
ollehar1 has quit [Ping timeout: 252 seconds]
ollehar has quit [Quit: ollehar]
eikke has joined #ocaml
ollehar has joined #ocaml
ttamttam has quit [Quit: ttamttam]
contempt has quit [Remote host closed the connection]
contempt has joined #ocaml
Neros has joined #ocaml
<ollehar>
can I add dirs to CAML_LD_LIBRARY_PATH permanently from command line?
<ollehar>
nm, google found it
<wmeyer>
sure you can, it works the same as the similar gcc toolchain variables
* wmeyer
goin' to put fish & chips to the oven
<adrien>
or How to know someone lives in England
<wmeyer>
s/lives/dying/
<ollehar>
gah, now ocamlfind won't find my old libs
<ollehar>
updated ocamlfind with opam
<wmeyer>
adrien: morning
<wmeyer>
ollehar: better just reset your environment, and do it from scratch
<adrien>
wmeyer: :D
<Kakadu>
So, If I can't make an OCaml value to be stored always in the same location, I should generated a name for the value and allow access using Callback.register () ?
<Kakadu>
s/generated/generate/
<ollehar>
"interface mismatch on Int32" for package netsys
<ollehar>
could some packages be incompatible with 4.00.1?
<Kakadu>
ollehar: compilation error?
<adrien>
yes
<adrien>
ollehar: do you have the latest version?
<ollehar>
net sure, will check
<ollehar>
*not
Anarchos has joined #ocaml
<companion_cube>
is there some simple way to download web pages and parse their urls?
<companion_cube>
(maybe invoking an external tool rather than using ocamlnet...)
ttamttam has joined #ocaml
ttamttam has quit [Client Quit]
tane has joined #ocaml
<Kakadu>
wget?
<companion_cube>
ok, but then I'd like to extract the set of urls of the page
<companion_cube>
i'm looking into python...
<Kakadu>
You want to parse downloaded text?
<companion_cube>
well, sure
<companion_cube>
only to get the href in them, though
<adrien>
grep for something that looks like an URL
<adrien>
then parse against the RFC? there are a few libs for that
<companion_cube>
grep sounds like the simplest thing, good idea
<companion_cube>
I just want a proof of concept :)
<adrien>
99.9% (like all stats) of URIs will be simple to find and you probably don't care that much about deliberately obfuscated URIs anyway
<companion_cube>
grep -o 'http://[^ "]*' looks good enough
<adrien>
/o\
<companion_cube>
;)
<bernardofpc>
I don't know how many URLs are now JS-generated
<adrien>
<a href=http://foo.bar>baaaaaah</a>
<bernardofpc>
(like all adds)
<companion_cube>
adrien: you're supposed to put "", I think
<adrien>
companion_cube: supposed? we're talking about HTML ;-)
<companion_cube>
:)
<companion_cube>
rhaaa, there is no simple way to split a string into lines... -_-
<adrien>
do it on <[^]\+>
<adrien>
or >
<companion_cube>
wat
<companion_cube>
even in batteries, there is not any "lines : string -> string list" oO
<wmeyer>
companion_cube: I found ocamlnet and pcre a good way of doing such URL introspection
Yoric1 has joined #ocaml
Yoric has quit [Ping timeout: 246 seconds]
<adrien>
companion_cube: Str has it
<wmeyer>
companion_cube: let lines = String.nsplit str "\n" in
<wmeyer>
<wmeyer>
(Batteries)
<companion_cube>
but Str is not thread safe
<companion_cube>
wmeyer: oh, thanks
darkf has quit [Quit: Leaving]
<companion_cube>
hmm, too bad Batteries' modules export "print" functions, but not "fprintf"
leoncamel has joined #ocaml
ulfdoz has quit [Ping timeout: 255 seconds]
<ollehar>
why does ocamlfind keep installing in /usr/lib/ocaml/site-lib instead of .opam
<ollehar>
?
<ollehar>
findlib.conf is set to opam
Neros has quit [Ping timeout: 264 seconds]
ulfdoz has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
<ollehar>
nm, solved
leoncamel has quit [Ping timeout: 245 seconds]
ontologiae has joined #ocaml
<Kakadu>
cool, my app have stopped crashing
ollehar1 has joined #ocaml
<Kakadu>
pippijn: do u have any ideas how ocamlbrowser should look like?
<Kakadu>
i.e. You have mentioned you want new ocamlbrowser, did u write down what u expect?
pango is now known as pangoafk
tane has quit [Quit: Verlassend]
groovy2shoes has joined #ocaml
ollehar1 has quit [Ping timeout: 245 seconds]
groovy2shoes has quit [Quit: Computer has gone to sleep]
groovy2shoes has joined #ocaml
gnuvince has joined #ocaml
ttamttam has joined #ocaml
groovy2shoes has quit [Ping timeout: 260 seconds]
ttamttam has quit [Remote host closed the connection]
ontologiae has quit [Ping timeout: 255 seconds]
pangoafk is now known as pango
ollehar1 has joined #ocaml
awm22 has quit [Quit: Leaving.]
q[mrw] has joined #ocaml
leoncamel has joined #ocaml
smondet has joined #ocaml
oriba has joined #ocaml
Uvs has quit [Ping timeout: 252 seconds]
icarot has joined #ocaml
<ollehar1>
Error: This expression has type ('a, 'b) nat
<ollehar1>
but an expression was expected of type ('a, 'b s) nat
<ollehar1>
The type variable 'b occurs inside 'b s
<ollehar1>
Got that error
<orbitz>
ok
<ollehar1>
any idea how to define a plus for type level church numerals?
icarot has quit [Remote host closed the connection]
<oriba>
Eat one vlue down, while you add the other up
Uvs has joined #ocaml
icarot has joined #ocaml
icarot has quit [Client Quit]
oriba has quit [Quit: oriba]
leoncamel has quit [Ping timeout: 246 seconds]
yacks has joined #ocaml
ggole_ has joined #ocaml
ggole has quit [Ping timeout: 240 seconds]
ollehar has quit [Ping timeout: 246 seconds]
<ollehar1>
oriba: not so easy to do at type level :P :P
awm22 has joined #ocaml
q[mrw] has quit [Ping timeout: 255 seconds]
Uvs has quit [Ping timeout: 246 seconds]
Uvs has joined #ocaml
emmanuelux has quit [Quit: emmanuelux]
iZsh has quit [Quit: Coyote finally caught me]
pib1979 has joined #ocaml
ollehar1 has quit [Ping timeout: 264 seconds]
julm has left #ocaml []
ulfdoz has quit [Ping timeout: 260 seconds]
ollehar has joined #ocaml
ontologiae has joined #ocaml
ttamttam has joined #ocaml
def-lkb has quit [Quit: leaving]
mikurubeam has quit [Quit: +1 (Yes). -1 (No). i (What I have been trying to tell you all along).]
def-lkb has joined #ocaml
mikurubeam has joined #ocaml
watermind has joined #ocaml
eikke has quit [Ping timeout: 245 seconds]
ggole_ has quit []
ollehar1 has joined #ocaml
ewanas has joined #ocaml
<ollehar>
what is this?
<ollehar>
Assertion failed, file "camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml", line 284, char 8
<ollehar>
trying to make polymorphic recursive functions
Ptival has quit [Remote host closed the connection]
sw2wolf has joined #ocaml
pkrnj has joined #ocaml
ontologiae has quit [Ping timeout: 240 seconds]
Ptival has joined #ocaml
mikurubeam has quit [Quit: +1 (Yes). -1 (No). i (What I have been trying to tell you all along).]
groovy2shoes has joined #ocaml
Kakadu has quit []
ewanas has quit [Quit: ChatZilla 0.9.90 [SeaMonkey 2.16.2/20130317033554]]
cdidd has quit [Read error: Connection reset by peer]
mikurubeam has joined #ocaml
Neros has joined #ocaml
ttamttam has left #ocaml []
answer_42 has quit [Quit: WeeChat 0.4.0]
Neros has quit [Ping timeout: 245 seconds]
Yoric1 has quit [Ping timeout: 264 seconds]
ulfdoz has joined #ocaml
ollehar has quit [Ping timeout: 255 seconds]
Neros has joined #ocaml
darkf has joined #ocaml
Uvs has quit [Quit: Uvs]
sw2wolf has left #ocaml []
BiDOrD has quit [Quit: No Ping reply in 180 seconds.]
iZsh has joined #ocaml
BiDOrD has joined #ocaml
ousia has joined #ocaml
troydm has quit [Ping timeout: 256 seconds]
BlackBook has joined #ocaml
<BlackBook>
Compiling OCaml (ocaml-4.00.1) as it's a dependency for some other software I want to play with, I get a compilation error: http://pastebin.com/unnCAeSs
<BlackBook>
FYI and all that.
ollehar1 has quit [Ping timeout: 245 seconds]
awm22 has quit [Read error: Connection reset by peer]
awm22 has joined #ocaml
awm221 has joined #ocaml
awm22 has quit [Read error: Connection reset by peer]
groovy2shoes has quit [Quit: Computer has gone to sleep]