companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.14.0 released: https://ocaml.org/releases/4.14.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Tuplanolla has quit [Quit: Leaving.]
omegatron has quit [Quit: Power is a curious thing.It can be contained, hidden, locked away,and yet it always breaks free.]
bobo_ has joined #ocaml
spip has quit [Ping timeout: 255 seconds]
raskol has joined #ocaml
<greenbagels> im trying to write a function that prints a string to stdout with a fixed character limit per line
<greenbagels> now from profiling my program i suspect this function is extremely inefficient, so im wondering if i have a poor grasp on good practices for handling strings
<greenbagels> here it is https://p.sicp.me/kBaxL.ocaml
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <hockletock> if you have a width of w and a string of length n * w you make n substrings totaling w * n * (n+1)/2 characters
<d_bot> <geoff> that'll be allocating a lot of strings
<d_bot> <NULL> If you make your function recurse over an index instead of the whole string you will have fewer allocations
<greenbagels> so basically you're saying only generate a substring for the line-to-be-printed, and recurse with the entire parent string + moving index?
<greenbagels> hm ok ill try that
<greenbagels> that would still be making n substrings, but totalling n*w characters (so linear instead of quadratic?)
<greenbagels> well, in the character count
<d_bot> <hockletock> You can also copy w characters into a buffer (with Buffer.add_substring), then either dump the buffer and reuse it or append a newline and dump the buffer at the end
<d_bot> <geoff> the append newline to a buffer way would probably be the most efficient
<d_bot> <NULL> Repeatedly allocating and freeing a string with constant length shouldn't take much time at all
<d_bot> <RegularSpatula> `print_endline` flushes every time...maybe that's part of the slowness
<greenbagels> hm ok
adanwan has quit [Remote host closed the connection]
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
adanwan has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<greenbagels> that worked!
<greenbagels> now my program goes from taking more than a few hours to run, to 4 seconds
<greenbagels> haha thank you all; these small toy problems are wonderful to learn from
<Corbin> Nice.
vicfred has joined #ocaml
Haudegen has joined #ocaml
raskol has quit [Ping timeout: 256 seconds]
hannes__ is now known as hannes
Serpent7776 has joined #ocaml
mro has joined #ocaml
motherfsck has quit [Ping timeout: 244 seconds]
motherfsck has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
gravicappa has joined #ocaml
vicfred has quit [Quit: Leaving]
aspe has joined #ocaml
motherfsck has quit [Ping timeout: 255 seconds]
motherfsck has joined #ocaml
trev has joined #ocaml
gravicappa has quit [Ping timeout: 272 seconds]
gravicappa has joined #ocaml
mro has quit [Remote host closed the connection]
mbuf has joined #ocaml
olle has joined #ocaml
olle has quit [Ping timeout: 246 seconds]
mro has joined #ocaml
wingsorc__ has quit [Ping timeout: 244 seconds]
dinosaure1 is now known as dinosaure
Sankalp has quit [Ping timeout: 255 seconds]
aspe has quit [Quit: aspe]
Sankalp has joined #ocaml
olle has joined #ocaml
DNH has joined #ocaml
mro has quit [Remote host closed the connection]
kakadu_ has joined #ocaml
kakadu has quit [Ping timeout: 276 seconds]
gahr has quit [Quit: leaving]
gahr has joined #ocaml
bartholin has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
Haudegen has quit [Quit: Bin weg.]
omegatron has joined #ocaml
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
Anarchos has joined #ocaml
mro has joined #ocaml
mro_ has joined #ocaml
mro has quit [Ping timeout: 246 seconds]
bobo_ has quit [Ping timeout: 240 seconds]
bobo_ has joined #ocaml
Haudegen has joined #ocaml
mro_ has quit [Read error: Connection reset by peer]
mro has joined #ocaml
infinity0 has quit [Ping timeout: 258 seconds]
infinity0 has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
raskol has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
cedric has joined #ocaml
raskol has quit [Ping timeout: 272 seconds]
mro has joined #ocaml
waleee has joined #ocaml
vicfred has joined #ocaml
mro has quit [Quit: Leaving...]
Tuplanolla has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
rgrinberg has joined #ocaml
kakadu has joined #ocaml
kakadu_ has quit [Ping timeout: 272 seconds]
cedric has quit [Quit: Konversation terminated!]
trev has quit [Remote host closed the connection]
wonko- has joined #ocaml
Serpent7776 has quit [Read error: Connection reset by peer]
Haudegen has joined #ocaml
Sankalp has quit [Ping timeout: 246 seconds]
mbuf has quit [Quit: Leaving]
Sankalp has joined #ocaml
olle has quit [Remote host closed the connection]
xenu has quit [Quit: Lost terminal]
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
raskol has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
<d_bot> <dolly> Does the OCaml native code compiler compile the ZINC bytecode or does it get split off at a separate step of compilation?
<companion_cube> it splits off during the compilation
<d_bot> <dolly> So long before any bytecode is generated?
<companion_cube> the native and bytecode compilation pipelines share a common prefix
<companion_cube> and fork at some point
<companion_cube> a call to the compiler doesn't compile into both, just into one
<d_bot> <dolly> Yeah I figured, I'm mostly curious where that is, as a native code compiler could potentially just compile the bytecode rather than interpret it.
<companion_cube> there are more optimisation passes done in the native compiler
<companion_cube> not sure exactly why, but still, that's how it is
<companion_cube> (and things that might be hard to do from bytecode, like register allocation)
<d_bot> <dolly> Yeah it'd depend heavily on the machine how hard register allocation might be. I find the line in general blurry as a lot of LISP compilers are native code compilers but I believe they have their own abstract machine they sort of compile to before optimizing and generating out native code
<companion_cube> ocaml is a lot more "batch", I think
<d_bot> <dolly> Gotcha, so it's a batch compiler that does a more UNIX style linking?
<companion_cube> yep
<companion_cube> produces intermediate files, is able to do separate compilation, cross module inlining…
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot> <dolly> Do you know what ever happened to the mixin modules Xavier Leroy wrote about in the past? I've found that mixins are a nice idiom in certain scenarios
<companion_cube> I have no idea. What are mixins in this context?
<d_bot> <dolly> Basically you can supplant holes in a module that is assumed by the module to be filled in with a mixin module that can provide the service. This allows mutually recursive modules and a few other techniques
<d_bot> <dolly> I'd have to read about them again as it's been a while, but I find the technique useful in the Common Lisp context
Anarchos has joined #ocaml
<companion_cube> that doesn't sound like OCaml :)
<d_bot> <dolly> the paper was called "Mixin modules in a call-by-value setting" By Tom Hirschowitz and Savier Leroy
<companion_cube> what's the date?
<d_bot> <dolly> not quite sure, the latest reference was from 2001
<d_bot> <dolly> ahh the filename says 2002 apparently
olle has joined #ocaml
rgrinberg has joined #ocaml
<dh`> if it was from 2002 and it's not been merged, it's a safe assumption it's currently dead, question would be why :-/
gereedy has joined #ocaml
raskol has quit [Ping timeout: 244 seconds]
gravicappa has quit [Ping timeout: 256 seconds]
mro has joined #ocaml
bartholin has quit [Quit: Leaving]
gereedy has quit [Quit: gereedy]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
waleee has quit [Ping timeout: 258 seconds]
wingsorc__ has joined #ocaml
waleee has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
waleee has quit [Ping timeout: 252 seconds]
waleee has joined #ocaml
wonko- has quit [Ping timeout: 258 seconds]
wonko- has joined #ocaml
zebrag has joined #ocaml
sagax has quit [Excess Flood]
Haudegen has quit [Ping timeout: 255 seconds]
mro has quit [Quit: Leaving...]
raskol has joined #ocaml
olle has quit [Ping timeout: 255 seconds]
raskol has quit [Ping timeout: 258 seconds]
motherfsck has quit [Ping timeout: 255 seconds]
<pgiarrusso> The latest work on mixins modules in an ML context is the MixML paper
xenu has joined #ocaml
rgrinberg has joined #ocaml
<pgiarrusso> but the complexity is nontrivial, and they come with recursive modules which don't seem necessarily that popular.
raskol has joined #ocaml
xenu has quit [Client Quit]