adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.2 announced http://ocaml.org/releases/4.02.html | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
jwatzman|work has quit [Quit: jwatzman|work]
thomasga has quit [Quit: Leaving.]
ollehar1 has quit [Quit: ollehar1]
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ygrek has quit [Ping timeout: 240 seconds]
tmtwd has quit [Ping timeout: 260 seconds]
jao has quit [Ping timeout: 264 seconds]
govg has quit [Quit: leaving]
govg has joined #ocaml
jao has joined #ocaml
jao has quit [Remote host closed the connection]
jao has joined #ocaml
claudiuc_ has quit [Remote host closed the connection]
MrScout has quit [Remote host closed the connection]
psy_ has joined #ocaml
govg has quit [Ping timeout: 240 seconds]
jao has quit [Ping timeout: 246 seconds]
struktured has joined #ocaml
pyon has quit [Quit: It's time for your reckoning...]
pyon has joined #ocaml
dejanr has quit [Quit: Textual IRC Client: www.textualapp.com]
tennix has joined #ocaml
malc_ has quit [Quit: leaving]
ncthom91 has joined #ocaml
badkins has quit [Remote host closed the connection]
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
darkf has joined #ocaml
Reku has joined #ocaml
<Reku> So is anyone here or are you all idle? Just wondering.
badkins has joined #ocaml
badkins has quit []
<jyc> nobody's here, not even me
cdidd has quit [Remote host closed the connection]
ncthom91 has joined #ocaml
cdidd has joined #ocaml
<Reku> Lol.
Natanaiel has joined #ocaml
<Natanaiel> when I wanna compile piqilib I get this error: http://pastebin.com/6EgKuhqk any suggestion?
<Natanaiel> the line is this: <:expr< $id:i$ . ( $e$ ) >>
mal`` has quit [K-Lined]
toomuchtvrotsurb has quit [Remote host closed the connection]
kdef has joined #ocaml
mal`` has joined #ocaml
toomuchtvrotsurb has joined #ocaml
toomuchtvrotsurb has quit [Ping timeout: 246 seconds]
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
MercurialAlchemi has joined #ocaml
Reku has left #ocaml [#ocaml]
<Natanaiel> how do u really compile piqilib with that bug?! http://pastebin.com/6EgKuhqk
kdef has quit [Read error: Connection timed out]
tmtwd has joined #ocaml
manizzle has quit [Ping timeout: 246 seconds]
Bhavya has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 244 seconds]
tmtwd has quit [Remote host closed the connection]
tmtwd has joined #ocaml
psy_ has quit [Ping timeout: 245 seconds]
seliopou has quit [Ping timeout: 265 seconds]
manizzle has joined #ocaml
ncthom91 has joined #ocaml
Natanaiel has quit [Quit: Leaving.]
shinnya has quit [Ping timeout: 260 seconds]
sqweek has quit [Ping timeout: 244 seconds]
sqweek has joined #ocaml
AlexRussia has joined #ocaml
psy_ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
psy_ has joined #ocaml
tmtwd has quit [Remote host closed the connection]
kushal has joined #ocaml
Algebr has joined #ocaml
martintrojer has quit [Read error: Connection reset by peer]
martintrojer has joined #ocaml
<Algebr> I'm trying to read everything from a TCP socket but am having trouble, here is the relevant function and commentary http://pastebin.com/ZD5bkJap
profan has quit [Remote host closed the connection]
<adrien> Algebr: Core?
<adrien> 1024 is lower than an MTU so it's not a very good value btw
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<adrien> you need to stop thinking about "all the data" probably
<adrien> do it in an asynchronous and non-blocking way
<adrien> lwt, select, something like that
<Algebr> no core, just unix.
<Algebr> what is MTU
<Algebr> I don't care about blocking issues
<adrien> see wp for mtu
<Algebr> okay what is wp
<adrien> wikipedia
<adrien> sorry was on the phone
<adrien> basically on ethernet you have a Maximum Transmit Unit (Size) (iirc that's the right name)
<adrien> which is 1500 bytes usually
<adrien> 9000 bytes for jumbo frames but you never see them through the Internet
<adrien> (some do though)
<Algebr> Is there a way to programmatically find the MTU?
<adrien> and data will come in chunks of at most MTU - overhead
meteo__ has quit [Ping timeout: 250 seconds]
<adrien> (actually it's not true with fragmentation but TCP will do its best to avoid it)
<adrien> Algebr: yes
<adrien> there are ioctls
<adrien> but don't worry about that
<adrien> Unix.read will return when there is data
<Algebr> why is a value less than MTU bad? wouldn't it be only bad if the value was greater than MTU
<adrien> even if you ask for 1500 and there is 1 only, it will return with 1 byte of data in your buffer
<Algebr> adrien: but do you see any concrete issues with that code sample?
<adrien> it's difficult to say without spending more time on it but it looks
<adrien> OK
<adrien> to debug I would build as native code and run under strace
<Algebr> sigh. I thought it was okay too but the second version just stalls, it doesn't get data.
<adrien> (strace -tt -f -o log -s 128 <your_command>)
<adrien> (writes to the file "log")
<adrien> strace
sh0t has joined #ocaml
cdidd has quit [Ping timeout: 265 seconds]
ely-se has joined #ocaml
Algebr has quit [Ping timeout: 244 seconds]
ollehar has joined #ocaml
gargaml has joined #ocaml
grouzen has joined #ocaml
gargaml has quit [Ping timeout: 244 seconds]
gargaml has joined #ocaml
mea-culpa has joined #ocaml
yomimono has joined #ocaml
zpe has joined #ocaml
wagle has quit [Read error: Connection reset by peer]
wagle has joined #ocaml
Haudegen has quit [Ping timeout: 260 seconds]
Haudegen has joined #ocaml
yomimono has quit [Ping timeout: 246 seconds]
AlexRussia has quit [Read error: Connection reset by peer]
sh0t has quit [Remote host closed the connection]
BitPuffin|osx has quit [Ping timeout: 250 seconds]
toomuchtvrotsurb has joined #ocaml
toomuchtvrotsurb has quit [Ping timeout: 260 seconds]
octachron has joined #ocaml
martinium has quit [Quit: Leaving]
<companion_cube> http://cedeela.fr/ocaml-compiler-hacking-how-to-add-a-primitive.html if anyone is interested in a small glance at OCaml compiler's primitives
dsheets has joined #ocaml
<octachron> companion_cube, it is always nice to see some documentation for the compiler :-)
<adrien_znc> not blog posts!
<adrien_znc> or blaaaaaag ones
<companion_cube> it's not official and it's not documentation! :p
<adrien_znc> you love github, you can do a PR that won't take months to be merged!
<companion_cube> a PR to what?
<adrien_znc> for doc in the compiler
<companion_cube> I don't know enough to do that
<octachron> Sometimes, I muse about make a PR to translate french comments in the compiler
<ely-se> lol, non-English text in code
<adrien_znc> comments*
<companion_cube> octachron: that would be nice
<companion_cube> also, I'd like to add colors to tests (meh, boring) and markdownify the text files
thomasga has joined #ocaml
<adrien_znc> get rid of the makefile recursivity in the testsuite please!
<rks`> :D
<companion_cube> the makefiles are a bit frightening
<adrien_znc> but it takes 1 minutes to make clean that part of the compiler for no good reason
<adrien_znc> you'll get the time back quickly
kushal has quit [Quit: Leaving]
<octachron> part of the problem with translating comments is deciding what to do with very old (or useless) comments
kushal has joined #ocaml
<adrien_znc> dd
<octachron> for instance, there is a long french todo comment in ctypes.ml dating back from 1997...
<adrien_znc> dd
<adrien_znc> dd
<adrien_znc> dd
<adrien_znc> dd
<adrien_znc> d20j
thomasga has quit [Ping timeout: 264 seconds]
<mrvn> Nothing lasts as long as a ToDo. :(
cdidd has joined #ocaml
ely-se has quit [Quit: leaving]
thomasga has joined #ocaml
gustav___ has quit [Ping timeout: 246 seconds]
martintrojer has quit [Max SendQ exceeded]
martintrojer has joined #ocaml
struktured has quit [Ping timeout: 245 seconds]
oscar_toro has quit [Ping timeout: 272 seconds]
oscar_toro has joined #ocaml
mengu has joined #ocaml
mengu has quit [Changing host]
mengu has joined #ocaml
siddharthv_away is now known as siddharthv
seliopou has joined #ocaml
_andre has joined #ocaml
mengu has quit [Remote host closed the connection]
struktured has joined #ocaml
sqweek has quit [Ping timeout: 240 seconds]
sqweek has joined #ocaml
yomimono has joined #ocaml
thomasga has quit [Quit: Leaving.]
libertas has joined #ocaml
dsheets has quit [Ping timeout: 240 seconds]
<struktured> def`: is merlin responsible for highlighting missing parentices? Found a bug in that..is it something like ocp-syntax I should report to?
govg has joined #ocaml
<struktured> def`: here's probably simplest example: http://i.imgur.com/XrAJsiB.png
govg has quit [Client Quit]
govg has joined #ocaml
<rks`> if merlin is reporting that error getting your cursor on that line should display an error message
<rks`> like « Syntax error inside 'module', expecting '.' or '(' »
<struktured> yeah it doesnt show that, just the red background
<struktured> but in general merlin is working as expected, and this is only exception I can find to the syntax verifier
<rks`> oh and indeed, the parenthesis seems correct in your example
<rks`> so => it's not merlin
<struktured> then who to blame...?
mengu has joined #ocaml
mengu has joined #ocaml
<rks`> if no error is reported, probably just your vim syntax file ?
<struktured> maybe I can fix it myself then..
<rks`> best of luck :)
<struktured> I aint afraid of no regex...thanks for the help though
tennix has quit [Ping timeout: 272 seconds]
ceryo has joined #ocaml
tmtwd has joined #ocaml
obadz has quit [Ping timeout: 265 seconds]
ely-se has joined #ocaml
obadz has joined #ocaml
struktured has quit [Ping timeout: 244 seconds]
tmtwd has quit [Ping timeout: 265 seconds]
ely-se has quit [Quit: leaving]
ely-se has joined #ocaml
grouzen has quit [Ping timeout: 240 seconds]
govg has quit [Quit: leaving]
siddharthv is now known as siddharthv_away
BitPuffin|osx has joined #ocaml
ely-se has quit [Quit: leaving]
ely-se has joined #ocaml
curiosity_ has joined #ocaml
<curiosity_> Is it possible to estimate when opam 1.3 with windows support will be released?
ollehar has quit [Ping timeout: 244 seconds]
libertas has quit [Ping timeout: 256 seconds]
dsheets has joined #ocaml
thomasga has joined #ocaml
thomasga has quit [Quit: Leaving.]
tmtwd has joined #ocaml
thomasga has joined #ocaml
badkins has joined #ocaml
tennix has joined #ocaml
libertas has joined #ocaml
libertas has quit [Ping timeout: 244 seconds]
grouzen has joined #ocaml
libertas has joined #ocaml
<bernardofpc> gtg: ely-se> Has anyone installed OCaml and OPAM on Gentoo? -> kindof works, but not so nicely right now because they haven't updated everything
<bernardofpc> (the chan-recommended route is to install the minimum from your distro, then install again everything from opam, which will compile ocaml twice, but it should give you the least headaches)
tmtwd has quit [Ping timeout: 246 seconds]
<bernardofpc> it would be nice if portage could understand opam and use it to install globaly the programs (say on a shared machine, but nobody seems to care about this anymore)
zpe_ has joined #ocaml
mengu has quit [Remote host closed the connection]
mea-culpa has quit [Remote host closed the connection]
zpe has quit [Ping timeout: 244 seconds]
<bernardofpc> btw, speaking of terminals, WHY on earth does utop fill lines with spaces and not '\n' ?
<mrvn> to overwrite what was there before?
<bernardofpc> I can't believe this is the only way, but well, terminals maybe are stupid
<seliopou> dsheets are those the only names you've come up with?
<seliopou> I haven't thought of anything better so if so, just go for it
jao has joined #ocaml
<dsheets> seliopou, hmm? for subset? I haven't thought too long
<ely-se> What's the new keyword for?
<ely-se> I tried to use it as an identifier but in vain.
<ely-se> bernardofpc: yeah I got it to work. Installed only the compiler and opam with Portage
<ely-se> no, only the compiler. I installed opam from source
<bernardofpc> yeah, but on ~amd64 I got blocked on the compiler
<ely-se> I unmasked that as I'm fine with an unstable OCaml compiler. I don't use it in production anyway.
<bernardofpc> so I have now only 4.02.1, because some stupid package blocks 4.02.3 (something about camlp4)
<ely-se> I have 4.02.3 :)
<bernardofpc> yeah, probably because you did not install opam from ::gentoo
<bernardofpc> opam pulls cudf, whose pacakge still wants only ocaml at most 4.02.1
<ely-se> yeah I couldn't install opam
<ely-se> it had a conflict with ocaml, hence I built it from source and installed it into $HOME/software
<Drup> ely-se: as I told you, once you have opam, which compiler you have in your system in unimportant
<Drup> just use the switch mecanism
<ely-se> I did. :p
<Drup> right :)
<ely-se> though I don't think I can uninstall the ocaml compiler from Portage now
<bernardofpc> you could, because you have opam from source
<bernardofpc> but i'd not say it's worth it
<Drup> yeah, you can
<ely-se> ok lemme try
<ely-se> yeah still seems to work :p
<Drup> you should nuke the "system" switch in opam
<ely-se> awesome!
<ely-se> how do I do that?
<ely-se> ah did it, opam switch remove system
tmtwd has joined #ocaml
govg has joined #ocaml
kushal has quit [Quit: Leaving]
ollehar has joined #ocaml
govg has quit [Quit: leaving]
govg has joined #ocaml
ely-se has quit [Quit: leaving]
ollehar has quit [Ping timeout: 246 seconds]
marsam has joined #ocaml
Bhavya has quit [Quit: Quit the channel]
GeorgeHahn has joined #ocaml
govg has quit [Quit: leaving]
lordkryss has joined #ocaml
mcclurmc has quit [Read error: Connection reset by peer]
mcclurmc has joined #ocaml
mengu has joined #ocaml
thomasga has quit [Quit: Leaving.]
psy_ has quit [Ping timeout: 246 seconds]
tristero has quit [Ping timeout: 246 seconds]
ely-se has joined #ocaml
mengu has quit []
ely-se has quit [Quit: leaving]
manizzle has quit [Ping timeout: 252 seconds]
tane has joined #ocaml
<theblatt1> is there a way to dynamically link ocaml modules together?
theblatt1 is now known as theblatte
<Drup> theblatte: the dynlink module
<theblatte> Drup: I'm struggling to actually use it, I don't understand what it does I guess
<theblatte> does it even work with ".cmx" files?
<theblatte> http://roscidus.com/blog/blog/2013/07/07/ocaml-binary-compatibility/#using-dynlink << this does what I want, but he needed to patch Dynlink to expose a "load_module" function
slash^ has joined #ocaml
<theblatte> actually it doesn't do native code, so not quite what I want
ely-se has joined #ocaml
ely-se has quit [Client Quit]
psy_ has joined #ocaml
<Drup> dynlink works with native code
<dsheets> cmxs
psy_ has quit [Max SendQ exceeded]
psy_ has joined #ocaml
<theblatte> Dynlink works the wrong way around for me: I'm trying to link a library, so I need to be able to load the module
<Drup> try that
<theblatte> his test case prints "choucroute", I'm sort-of convinced
<Drup> :D
<theblatte> however I would like something that works for others than me, I don't think patching ocaml is an option here
<Drup> It could be integrated in 4.03, if you provide feedback and a compeling use case
govg has joined #ocaml
<theblatte> is there a horrible solution based on -output-obj?
tennix has left #ocaml ["WeeChat 1.2"]
govg has quit [Client Quit]
AlexRussia has joined #ocaml
govg has joined #ocaml
malc_ has joined #ocaml
zpe_ has quit [Remote host closed the connection]
govg has quit [Ping timeout: 255 seconds]
govg has joined #ocaml
xet7 has joined #ocaml
<theblatte> looks like opam doesn't come with a libasmrun.a that can be used with -output-obj
<theblatte> nor does it let me add -fPIC to the compilation flags of ocaml
<Drup> there are switchs for fPIC, I think
<Drup> hum, only for 4.02.1, it should be updated
<Drup> It's 4.02.1+PIC
<theblatte> ah, thx!
thomasga has joined #ocaml
octachron has quit [Quit: Leaving]
fraggle_ has quit [Remote host closed the connection]
govg has quit [Ping timeout: 250 seconds]
govg has joined #ocaml
yomimono has quit [Ping timeout: 240 seconds]
ollehar has joined #ocaml
fraggle_ has joined #ocaml
MercurialAlchemi has joined #ocaml
ncthom91 has joined #ocaml
ely-se has joined #ocaml
ely-se has quit [Client Quit]
ely-se has joined #ocaml
gustav_ has joined #ocaml
govg has quit [Ping timeout: 246 seconds]
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ygrek has joined #ocaml
manizzle has joined #ocaml
<ollehar> why is java faster than ocaml?
<Drup> millions of dollar poured in a tracing JIT ?
<ollehar> drup, that's the only reason?
<Drup> pretty much, yeah
jao has quit [Ping timeout: 256 seconds]
<ely-se> Java is not faster than OCaml.
<ely-se> Program performance isn't a property of a programming language.
<ollehar> drup, but ocaml can be aot compiled.
<Drup> I agree I can be aot, but I refuse to let you compile me.
<Drup> =')
<ely-se> JIT compilation may result in faster programs than AOT compilation since the JIT compiler knows things the AOT compiler can't possibly know.
dsheets has quit [Ping timeout: 245 seconds]
<ely-se> Typically at the cost of longer boot times.
<Drup> ely-se: saying "Program performance isn't a property of a programming language." is highly misleading
<ely-se> Why?
<companion_cube> because languages usually have few implementations
<companion_cube> and those implementations do have performance characteristics
<Drup> A language design can affect it's performances, regardless of the implementation.
<ollehar> put like this: why isn't ocaml as fast as C++?
<ollehar> because of gc?
<companion_cube> GC, lack of control over memory layout, the fact that there are more allocations in general
<ely-se> companion_cube: then it's a property of those implementations.
<companion_cube> it could be possible to write a more optimizing version of OCaml, I think
<companion_cube> ely-se: no, not the control of the layout
<companion_cube> nor the GC
<Drup> ely-se: to take a concrete example: ruby's design leads itself to very poor performance due to how reflexivity is integrated into the language
<companion_cube> ocaml has a GC, that's it
<companion_cube> it doesn't have a notion of value vs pointer
ygrek has quit [Ping timeout: 240 seconds]
<ely-se> Allocations in a compacting GC can be as fast as stack allocations.
<Drup> You can make it less slow, you can optimize some stuff, but the language has a whole isn't easy to optimize
<rks`> companion_cube: you can do manual memory management in ocaml if you want
<companion_cube> ely-se: some C++ programs do not allocate in their main loop
<companion_cube> in ocaml it's hard
<companion_cube> rks`: and hit the write barrier?
<rks`> no?
<rks`> just allocate outside the caml heap
<companion_cube> oh, right, but that won't work for the regular values, will it?
<companion_cube> you can probably write fortran-like programs in this way
govg has joined #ocaml
<ely-se> With OCamllex and Menhir, is it possible to manipulate tokens between lexing and parsing?
jwatzman|work has joined #ocaml
<ely-se> I want to automatically insert semicolons between certain token pairs.
<Drup> You can probably do that, yes
<Drup> ely-se: ocamllex gives you a function of type (lexbuf -> token)
<Drup> you can take that, do a bit of magic to insert the token you want
<Drup> and gives the new funtion to menhir
<ely-se> and Menhir takes that function, so I guess I have to do a lookahead
<ely-se> and since that function isn't pure I have to keep track of lots of things I suppose
<scythe-> "can be as fast" is an extremely misleading phrase
<Drup> ely-se: I don't think it's that complicated
<ollehar> how about this one: if I remove __destruct function from PHP, then I can have a purely GC language instead of ref count + GC. would that make a faster language?
<scythe-> "are as fast on average" does not always follow
<Drup> ollehar: Not really
<ollehar> ok
<ollehar> drup, but simpler implementation?
<mrvn> ollehar: ref count and GC seems like overly complicated
<mrvn> Does it only look at objects with ref count 0 or does it free objects with ref count 0 imediatly and only GCs for cyclic structures?
<ely-se> ugh, what an awful API
MrScout has joined #ocaml
<ollehar> mrvn: as ely-se mentioned yesterday-or-so, PHP has destruct functions that should be called when an object falls out of scope.
<ely-se> No, when its last reference is gone.
<ollehar> ely-se: ok
<ollehar> then GC for arrays...?
thomasga has quit [Quit: Leaving.]
<ollehar> hm, but refcount should be possible during compile time, right?
manizzle has quit [Ping timeout: 255 seconds]
<Drup> (not tested)
<Drup> (also, it doesn't handle end of lexbuf)
toomuchtvrotsurb has joined #ocaml
<ely-se> I have a better idea.
<ely-se> I'll read the entire buffer into a list, replace newlines by semicolons where appropriate in that list, then return a function which reads from that list.
<Drup> not fabulously efficient
<ely-se> I couldn't care less.
<ely-se> It's actually maintainable.
<Drup> ely-se: can't you just change the lexer to emit COMMA on newlines ?
<ely-se> No, since not all newlines must be converted into semicolons.
<ely-se> Only those that occur between certain tokens.
<Drup> I see
<ely-se> E.g. you don't want a semicolon between 'a' and '|>' in "a <newline> |> f"
<ely-se> but you do want them between 'f()' and 'g()' in "f() <newline> g()"
<Drup> and what about "f () g ()" ?
<ely-se> That's a syntax error; you have to put a semicolon there explicitly.
<Drup> your heuristic seems very flawed ?
<ely-se> No, it's not.
<ely-se> Many languages do it this way and it works very well.
<Drup> oh, application is with parens ?
<Drup> f (x, y, z) ?
<ely-se> Yeah. :p
<Drup> right, then yeah
<Drup> filthy language who doesn't support partial application! Two
<Drup> s/Two/:p/
<mrvn> isn't |> parsed as token (BinOperator "|>")? Should be easy to emit ; on newline except when the next token is an operator.
darkf has quit [Quit: Leaving]
ollehar has quit [Remote host closed the connection]
ollehar has joined #ocaml
yomimono has joined #ocaml
tane has quit [Quit: Verlassend]
ncthom91 has joined #ocaml
grouzen has quit [Ping timeout: 255 seconds]
<ely-se> Drup: it works :)
<Drup> Newline collapsing should really be done at the lexer level.
<ely-se> Yeha, why not. :p
<ely-se> fixed
<Drup> also, I feel you could do that simply with a parser rule ...
<Drup> everytime you expect a semicolo, just put it to be valid to have a newline, and you are done ...
<ely-se> time for dinner. bye!
ely-se has quit [Quit: Leaving...]
<mrvn> semicolon := SEMICOLON | NEWLINE, done.
<Drup> assuming you don't get conflicts
<mrvn> then using newline instead of semicolon would be ambigious
<Drup> conflicts in menhir doesn't mean it's ambigious, it just means you didn't hit menhir hard enough.
<Drup> (or that it's not LR(1))
jwatzman|work has quit [Quit: jwatzman|work]
manizzle has joined #ocaml
ollehar has quit [Ping timeout: 244 seconds]
eventualbuddha has quit [Quit: Connection closed for inactivity]
ely-se has joined #ocaml
<ely-se> back
yomimono has quit [Ping timeout: 246 seconds]
averell has joined #ocaml
lobo has joined #ocaml
dwoos has quit [Quit: ZNC - http://znc.in]
<maurer> If I call into an OCaml closure registred via Callback.register from C, and receive a value*, what do I have to do on the C side in order to gaurantee value* won't be collected?
<maurer> (and then again what do I need to do to drop the root later to allow ocaml to collect it)
<flux> maurer, you can register it as a GC root
<flux> but if this is just a matter of executing your function, you should use the macros associated to dealing with arguments and return avlues
<flux> maurer, so what is your use case?
<maurer> flux: I am trying to bind an OCaml library as a C library so that it can be called from C/C++ programs
<maurer> flux: I want to be able to return (opaque) values from the ocaml program so that the C interface can mirror the ocaml interface for the most part
<maurer> The macros in question seem to be intended for function scope, which does not work here, since I actually want to return the value* to other C code
<maurer> which may put it in a data structure, etc.
<Drup> maurer: you tried with ctypes' reverse bindings before fiddling with C directly ?
<maurer> tbh, I couldn't find any documentation on how to use ctypes reverse bindings, so I didn't consider it
<maurer> There was documentation on how to use callback.register, it just seems they don't expect pointers into the ocaml heap to live outside ocaml
<maurer> which is kind of what I want to do
marsam has quit [Remote host closed the connection]
<maurer> Drup: Is there some documentation I could read on ctypes reverse bindings?
AlexRussia has quit [Read error: Connection reset by peer]
<Drup> huuum, the .mli ? :D
<maurer> When I search for it I get a page and a half of how to call C from OCaml, followed by stuff about haskell
<maurer> An .mli is not documentation and you know it :(
<Drup> yeah
<dmbaturin> .mli is not documentation, it's better! ;)
<ely-se> No, it's not, unless there are comments that precisely define all computations and side-effects performed, as well as all preconditions expected and postconditions guaranteed.
<ely-se> IME lack of documentation is more annoying than writing documentation.
<flux> .mli is the reference documentation, wish many libraries came with a manual as well :)
<flux> also2 wish #show would know how to look for documentation within the .mli files..
<maurer> Ugh, at this point maybe I should just read how cstubs does it and mimic. This looks super annoying to do
<maurer> err, ctypes rather
kakadu has joined #ocaml
contempt has quit [Ping timeout: 272 seconds]
yomimono has joined #ocaml
slash^ has left #ocaml [#ocaml]
<maurer> Drup: As far as I can tell from reading the code for cstubs_inverted and from reading https://github.com/yallop/ocaml-ctypes-inverted-stubs-example I don't see any evidence that ctypes_inverted supports C pointers into the OCaml heap
contempt has joined #ocaml
dsheets has joined #ocaml
marsam has joined #ocaml
claudiuc has joined #ocaml
claudiuc_ has joined #ocaml
ericsmithvt has joined #ocaml
ericsmithvt has quit [Client Quit]
claudiuc has quit [Ping timeout: 256 seconds]
ollehar has joined #ocaml
ceryo has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
ygrek has joined #ocaml
struktured has joined #ocaml
govg has quit [Ping timeout: 260 seconds]
govg has joined #ocaml
MercurialAlchemi has quit [Ping timeout: 246 seconds]
xificurC has quit [Ping timeout: 240 seconds]
ygrek has quit [Ping timeout: 250 seconds]
ncthom91 has quit [Quit: Textual IRC Client: www.textualapp.com]
ygrek has joined #ocaml
ollehar has quit [Ping timeout: 240 seconds]
shinnya has joined #ocaml
<maurer> Hrm. Does anyone know how to create an OCaml string containing nulls from C?
<maurer> I see a function for creating a string, and a function for creating a string by copying a null terminated one
<maurer> but I don't see any mutators for the created string object, making it kind of hard to create a string with nulls
<flux> maurer, well, you could just look how the function to create ocaml strings from C is written
<flux> but perhaps there's another function, I haven't looked at the headers
<maurer> Oh, I see
<maurer> I can call String_val on the result of caml_alloc_string and get a char* I can blat into
<flux> yeah, that too
<flux> so you're looking the source now?
<flux> I guess caml_alloc_string itself already ensures the string is really null-terminated (regardless if its contains nulls or not)
<flux> all ocaml strings are
<maurer> Sure, the issue here is that my source is a C buffer which will frequently contain nulls, but I can just memcpy into String_val(caml_alloc_string(bufsize))
tmtwd has quit [Ping timeout: 255 seconds]
ncthom91 has joined #ocaml
_andre has quit [Quit: leaving]
tmtwd has joined #ocaml
ollehar has joined #ocaml
<ollehar> mrvn: you from hamburg?
oscar_toro has quit [Ping timeout: 246 seconds]
badkins has quit []
xet7_ has joined #ocaml
ollehar has quit [Ping timeout: 256 seconds]
__rlp has joined #ocaml
xet7 has quit [Ping timeout: 256 seconds]
ely-se has quit [Quit: Leaving...]
<__rlp> Do you guys have a default link to a "why learn ocaml" reference?
ygrek has quit [Ping timeout: 256 seconds]
<Drup> __rlp: what's your background ?
<__rlp> Drup: Python, Go mostly
<__rlp> Perl, C, PHP, JS, etc. at somet point
<__rlp> some
<__rlp> cool, I'll read that
<__rlp> thanks
<Drup> so yeah, this series of blog post should by right your alley
<Maelan> > writing GTK code in OCaml just seems to be much easier than with Python.
<Maelan> Weird, I never tried myself, but I always heard that GUI was a pain with OCaml.
<Maelan> Was I wrong?
<Drup> lablgtk receives a lot of undeserved dislike.
<Drup> Maelan: A good amount of that comes down to "it's a bit imperative and OO-like right in the middle of my functional code"
gargaml has quit [Quit: WeeChat 1.2]
<mrvn> GUI is the prime example for OO imho.
<mrvn> and doing functional OO is a huge pain
<Drup> mrvn: the oo system of ocaml is very nice though
<Drup> you can really do "functional oo" with it
<mrvn> Problem is matching that with the OO in existing GUI toolkits.
<mrvn> and the GC
<Drup> yeah
<Drup> but that's more of a general binding issue
<Maelan> Okay, thanks for this quick explanation!
<flux> I think lablgtk is nice, and is nicely documented. the downside is that it's so ocamly that the official gtk documentation might not always be helpful.
<mrvn> from what I remember of gtk is that the model/view concept is seriously lacking.
<mrvn> having huge lists or tables totaly breaks down and flickers.
<flux> I would love though to have more binding libraries that have sufficient documentation; ie. they one wouldn't need to refer to the main documentation except for some functional details
<mrvn> flux: unless they are so thin that the original docs work 1:1
<flux> mrvn, and if they are so thin they easily become unsafe or don't fit the ocaml environment well
<mrvn> depends on how complex and safe the original is
<flux> for example, no first class functions anywhere
<mrvn> I'm not opposed to have a realy thin ctypes layer with an extra module/functor/function/OO layer on top if you want it convenient.
<flux> well, if you only have that, then you could easily have unsafe bindings
<flux> and segfaulting ocaml programs is a bad place to be in ;)
<mrvn> that's fine by me if you don't have to use them
<mrvn> like String.unsafe_get
<flux> yes, it is the risk with any ocaml code that interacts with C
lobo has quit [Quit: leaving]
<mrvn> proper C code is quite type save if you replace the void * with 'a properly in the bindings.
<flux> or any C code in general ;)
<mrvn> The new ctypes seems to be able to generate stubs. I have to look into that for some things.
<flux> mrvn, most of it yes, I think the tricky parts are when C code holds references to ocaml values and when you need to release the resources
<flux> and when C code can make callbacks to ocaml code
<mrvn> callbacks should be fine. Holding the values is a huge problem.
<flux> well, not tricky to implement, but finding out that they are misimplemented can be difficult
<flux> in particular pinpointing the location of the actual error from some GC mishap
<mrvn> In my epoll bindings I have a hashtbl where I store the value with an unique int as key and I store the int in the C code.
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mrvn> Problem is something like Qts QModelIndex. You can store an int or pointer in it but you never get told when the QModelIndex gets deleted.
<mrvn> C libs that store values temporary need a release callback.
<flux> mrvn, btw, did you notice that optional feature in ocaml compiler that breaks type opaque = void*?
<mrvn> huh?
<flux> in other words, all boxed values must point to ocaml objects, except values that are inside objects tagged otherwise
<mrvn> you mean turning off outside pointers?
<flux> yes
<mrvn> Yeah. saw that mentioned recently here.
<flux> I'm not sure what the point was (perhas performance), but I guess it's going to break quite a few C bindings..
<mrvn> I guess it saves the GC from having to check every pointer against its heaps to see if it is inside.
<flux> I imagine it could be a nice saving when you have a lot of pointers and a lot of memory regions. though I'm not sure if there can really be more than 1 gc'd memory region :)
<flux> well, it's already two compares less per pointer, could be worth something
<mrvn> there are at least 2, minor and major
<mrvn> and you have to compare against lower and upper. that's 4
<flux> right. maybe with ocaml multicore even more.
<mrvn> also doesn't the GC create new heaps when it can't grow the old one?
<mrvn> For multicore I would think that each core has it's own minor heap
<def`> ocaml multicore yes, + for normal gc there is a non negligible speedup on 64 (I don't recall the number though)
<def`> "create new heaps", that's not different from a single non contiguous OCaml heap from the GC pov
<mrvn> that's what I ment. non-continious blocks of memory for the heap
kolko_ has joined #ocaml
<def`> yep, these non-contiguous region are indexed in the "gc pagetable", the purpose of this patch is to drop the table, at least during scanning
kolko has quit [Read error: Connection reset by peer]
<mrvn> Unfortunately the GC internal interface is hardly documented. I tried replacing the thread implementation when running ocaml on baremetal and never could get it to not crash after a while.
<def`> (it could still be useful for ad-hoc/magic polymorphic function)
<mrvn> def`: Having to box all C pointers sucks though.
<def`> mrvn: just turn them to int, they are opaque anyway
<def`> p|1, p&~1
<mrvn> def`: hmm, that is an idea.
<mrvn> There should be a Ptr_val and Val_ptr for that.
<mrvn> doesn't work for char* though.
<def`> the only problem would be for byte grained pointers
<mrvn> :)
<def`> but then, you're maybe not working at the appropriate granularity (or, there must be workarounds for most common cases :))
<mrvn> or you probably have an array and should be using Bigarray
<flux> so Val_aligned_ptr then :)
ncthom91 has joined #ocaml
<def`> :(
<def`> :)*
<mrvn> flux: too much to type
<flux> it's a proper punishment for writing C
<def`> +1
<mrvn> I'm not sure I've ever seen a non-aligned char * other than as pointer into a string during processing.
<flux> but you sure would be suprised if you would get another pointer out than what you put in :)
<mrvn> or pointer inside the data section of a larger structure.
ncthom91 has quit [Client Quit]
<flux> ..well, at least if you wouldn't know the specific details
<mrvn> flux: totaly
<mrvn> writing bindings is not for everyone.
ncthom91 has joined #ocaml
ncthom91 has quit [Client Quit]
<dsheets> the chan title is out of date... 4.02.3 is released
ollehar has joined #ocaml
xet7_ is now known as xet7
QuanticPotato has joined #ocaml
ncthom91 has joined #ocaml
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marsam has quit [Remote host closed the connection]
yomimono has quit [Ping timeout: 240 seconds]
QuanticPotato has quit [Remote host closed the connection]
spacebat has joined #ocaml
<spacebat> hi, I'm setting up emacs and wonder how to set up tuareg and utop to work together; while I can (setq tuareg-interactive-program "utop") this misses out on features in utop.el
reynir1 has joined #ocaml
reynir has quit [Read error: Connection reset by peer]
<spacebat> I'm happy enough with it as it stands, just figured I might be missing something
kakadu has quit [Remote host closed the connection]
GeorgeHahn has quit [Read error: Connection reset by peer]
Haudegen has quit [Ping timeout: 244 seconds]
manizzle has quit [Ping timeout: 256 seconds]
madroach has quit [Ping timeout: 264 seconds]
jao has joined #ocaml
madroach has joined #ocaml
Haudegen has joined #ocaml
ollehar has quit [Quit: ollehar]