gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0+beta1 http://permalink.gmane.org/gmane.comp.lang.caml.inria/49168
|marius| has quit [Remote host closed the connection]
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 260 seconds]
seafood has joined #ocaml
seafood has quit [Read error: Connection reset by peer]
seafood has joined #ocaml
joewilliams_away is now known as joewilliams
alexyk has joined #ocaml
alexyk has quit [Quit: alexyk]
|marius| has joined #ocaml
alexyk has joined #ocaml
joewilliams is now known as joewilliams_away
alexyk has quit [Quit: alexyk]
srcerer_ has joined #ocaml
srcerer has quit [Ping timeout: 240 seconds]
ccasin has quit [Quit: Leaving]
|marius| has quit [Remote host closed the connection]
alexyk has joined #ocaml
|marius| has joined #ocaml
seafood has quit [Read error: Connection reset by peer]
seafood has joined #ocaml
alexyk has quit [Quit: alexyk]
alexyk has joined #ocaml
aja has joined #ocaml
|marius| has quit [Remote host closed the connection]
|marius| has joined #ocaml
jakedouglas has quit [Quit: Leaving.]
alexyk_ has joined #ocaml
alexyk has quit [Ping timeout: 276 seconds]
alexyk_ is now known as alexyk
elehack has quit [Ping timeout: 265 seconds]
Associat0r has quit [Quit: Associat0r]
verte has joined #ocaml
jakedouglas has joined #ocaml
aja has quit [Read error: Connection reset by peer]
patronus has quit [Remote host closed the connection]
patronus has joined #ocaml
ttamttam has joined #ocaml
ttamttam has quit [Quit: Leaving.]
alexyk has quit [Quit: alexyk]
jakedouglas has quit [Quit: Leaving.]
ygrek has joined #ocaml
patronus has quit [Remote host closed the connection]
patronus has joined #ocaml
Amorphous has quit [Ping timeout: 246 seconds]
Amorphous has joined #ocaml
palomer has quit [Quit: Leaving]
seafood has quit [Quit: seafood]
jonafan_ has quit [Ping timeout: 240 seconds]
sepp2k has joined #ocaml
Associat0r has joined #ocaml
seafood has joined #ocaml
seafood has quit [Quit: seafood]
ygrek has quit [Ping timeout: 245 seconds]
ulfdoz_ has quit [Quit: Reconnecting]
ulfdoz has joined #ocaml
ygrek has joined #ocaml
<sdschulze> Hm, this is about the reason why bignum stuff in OCaml is rather slow: http://sdschulze.dnsalias.org/~soeren/eviladd.ml
<sdschulze> I currently fail to see a good way to optimize it, though.
<mfp> sdschulze: pointer tagging and escape analysis
<mfp> sdschulze: you can emulate the former (or its dual of sorts) using Obj
<sdschulze> Can you elaborate on the former?
<sdschulze> ah, ok, you mean using Obj.magic
<mfp> it's not really pointer tagging (using the LSBs in the pointers to encode the constructors, Big_int and Ratio in this case), but it's the same idea
<mfp> well, Obj.magic is just the means to do that with the current compiler/runtime, but this is something the compiler could do (if it were an optimizing one)
marteo has joined #ocaml
<sdschulze> I'm still not sure how your code addresses the problem that a new big_int is generated on every recursion.
<sdschulze> thereby generating garbage
<mfp> it avoids consing if the num fits in an int
<mfp> hence generating no garbage in that case
<sdschulze> ah, ok
<sdschulze> but still a lot in other cases
<mfp> yes
<sdschulze> No, with Big_int, the problem is that internally, the GMP stuff is imperative.
<sdschulze> It's just boxed by the Big_int package.
<sdschulze> in order to save the sign or something
Yoric has joined #ocaml
<sdschulze> The Java implementation of the pidigits benchmark also boxes, but it modifies in-place, generating no garbage.
mattam has quit [Ping timeout: 258 seconds]
<mfp> (Big_int doesn't use GMP BTW)
<sdschulze> ok, only MP then
<sdschulze> Wouldn't it be nice if there were some kind of attribute that made any data default to being stack-allocated?
<sdschulze> (and being copied to the heap if really necessary)
<mfp> you need escape analysis in order to make that safe, esp. in the presence of closures
<sdschulze> But it already works for floats.
<sdschulze> afk
<mfp> arg. yet another example of OCaml receiving little love in the comp lang bm game > http://shootout.alioth.debian.org/u64q/performance.php?test=pidigits
<mfp> the GMP-based prog doesn't compile because somebody didn't apt-get install libgmp-ocaml-dev, leaving only the big_int one around and making OCaml seem 4X slower
verte has quit [*.net *.split]
|marius| has quit [*.net *.split]
Tianon has quit [*.net *.split]
shachaf has quit [*.net *.split]
bitbckt has quit [*.net *.split]
thieusoai has quit [*.net *.split]
boscop has quit [*.net *.split]
drk-sd has quit [*.net *.split]
orbitz has quit [*.net *.split]
noj has quit [*.net *.split]
rudi_s has quit [*.net *.split]
verte has joined #ocaml
|marius| has joined #ocaml
boscop has joined #ocaml
thieusoai has joined #ocaml
Tianon has joined #ocaml
shachaf has joined #ocaml
drk-sd has joined #ocaml
orbitz has joined #ocaml
noj has joined #ocaml
rudi_s has joined #ocaml
bitbckt has joined #ocaml
<mehdid> mfp: do you know if those pages are still maintained?
<mfp> mehdid: AFAIK the game is still going on
<sgnb> are big numbers really needed for this?
<sgnb> the Haskell version doesn't seem so... but is quite cryptic as usual
<mehdid> mfp: Right. thanks for the pointer.
<mfp> sgnb: I believe it's using big ints (which the compiler defaults to unless you give type annotations IIRC)
<sgnb> maybe... Haskell syntax is really horrible...
elehack has joined #ocaml
<mfp> that program is fine, it's rather the likes of http://shootout.alioth.debian.org/u64/program.php?test=knucleotide&lang=ghc&id=3 which are sick
<mfp> planets :: Ptr Double
<mfp> planets = unsafePerformIO $ mallocBytes (7 * nbodies * 8) -- sizeOf double = 8
<mfp> hah!
<sgnb> there is comment in this line...
<sgnb> are there programs using the Obj module in this stuff?
<sgnb> unsafePerformIO sounds nasty
Anarchos has joined #ocaml
sdschulz` has joined #ocaml
sdschulze has quit [Ping timeout: 260 seconds]
elehack has quit [Quit: not a typewriter]
Tianon has quit [Ping timeout: 248 seconds]
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
sdschulz` has left #ocaml []
sdschulze has joined #ocaml
<sdschulze> mfp: Ah, OK, so the GMP one is faster?
<sdschulze> So unboxing tail-recursive calls should be considered non-trivial?
boscop has quit []
boscop has joined #ocaml
mattam has joined #ocaml
patronus has quit [Ping timeout: 260 seconds]
patronus has joined #ocaml
Yoric has quit [Quit: Yoric]
Yoric has joined #ocaml
Yoric has quit [Quit: Yoric]
chee has quit [Ping timeout: 265 seconds]
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 276 seconds]
chee has joined #ocaml
tautrimas has joined #ocaml
alexyk has joined #ocaml
verte has quit [Quit: ~~~ Crash in JIT!]
<sdschulze> Is there a good reason why floats are boxed in tail-recursion?
<tautrimas> Hello. I was hoping somebody knows a quick answer: how to open a hyperlink in the default system's browser from Ocaml?
<sdschulze> tautrimas: depends primarily on the operating system, probably
<tautrimas> sdschulze: but then how to solve this problem? I'm contemplating the option to leave the url for the user to copy paste into his browser. Is there no library suitable for this?
<adrien> tautrimas: should depend on your shell
<adrien> ah, no, ok
<adrien> tautrimas: xdg-open iirc
<tautrimas> adrien: I've written the GUI game and need it portable to windows also
chee is now known as fourthroatedcat
<tautrimas> btw, I'm using TK
<adrien> I don't know of anything portable so you'll probably want to match against Sys.os_type, if Unix, try xdg-open, if it's not available, you might try $BROWSER but it's not necessarily a graphical one (might be links) so fall back on firefox, if Windows, you'll probably have to deal with the registry
<tautrimas> adrien: hey, maybe windows have also some specific command for the default browser? I'll google it. Thanks for xdg-open so far!
<adrien> btw, anyone know of an easy windows registry library? ocaml-win32 does not on mingw.org (mingw-w64 should work) and is pretty big but iirc a few ocaml apps use the windows registry
<adrien> tautrimas: afaik it's stored in the registry, I have no idea where it is stored though
<adrien> np
<ygrek> cf. ShellExecute
<adrien> right, you can let windows "resolve" that by itself but you'll want a binding to it anyway
alexyk has quit [Ping timeout: 265 seconds]
tautrimas has quit [Remote host closed the connection]
boscop has quit [Ping timeout: 240 seconds]
boscop has joined #ocaml
alexyk has joined #ocaml
ftrvxmtrx has quit [Read error: Connection reset by peer]
alexyk has quit [Ping timeout: 246 seconds]
EliasAmaral has quit [Ping timeout: 265 seconds]
ftrvxmtrx has joined #ocaml
EliasAmaral has joined #ocaml
EliasAmaral is now known as dark
jakedouglas has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
psnively has joined #ocaml
psnively has left #ocaml []
ygrek has joined #ocaml
ftrvxmtrx has quit [Ping timeout: 248 seconds]
Yoric has joined #ocaml
Tianon has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
Tianon has joined #ocaml
Tianon has quit [Changing host]
Tianon has joined #ocaml
Yoric has quit [Ping timeout: 276 seconds]
fourthroatedcat is now known as chee
ulfdoz has quit [Read error: Operation timed out]
psnively has joined #ocaml
psnively has left #ocaml []
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
joewilliams_away is now known as joewilliams
letrec has joined #ocaml
iratsu has quit [Ping timeout: 240 seconds]
struktured has quit [Ping timeout: 245 seconds]
letrec has quit [Quit: http://irc2go.com/]
joewilliams is now known as joewilliams_away
ulfdoz has joined #ocaml
gluecklich has joined #ocaml
gluecklich has quit [Quit: http://irc2go.com/]
smalllatte has joined #ocaml
smalllatte has quit [Client Quit]
Gabelsbergerstra has joined #ocaml
<adrien> ftr, '/usr/bin/htmlview' might also be a default browser: worth trying if you want to get the default browser and everything else failed
Gabelsbergerstra has quit [Ping timeout: 252 seconds]
listmap has joined #ocaml
<listmap> Hey
<listmap> Can somebody explain why the count_map implementation is tail-recursive (see first code snippet on http://ocaml.janestreet.com/?q=node/71)?
jakedouglas has quit [Quit: Leaving.]
<sdschulze> listmap: Well, look at what it can possibly return.
<sgnb> listmap: it's not, is it?
<sgnb> I guess List.map is in Core.Std context
<sdschulze> Now I'm confused.
<sdschulze> The documentation says List.map is *not* tail-recursive.
<sgnb> sdschulze: it pretty clear, though: "INRIA's list functions are not tail-recursive, and ours are"
listmap has quit [Ping timeout: 252 seconds]
<sdschulze> yes
<sdschulze> I intuitively fail to see a problem with tail-recursive functions, though.
<sgnb> they can be more complicated to understand and to reason about
<sgnb> or even slower for small objects
<sdschulze> OK, Lisp just implements it as a language primitive.
<sgnb> how is that relevant?
<sdschulze> The problem is how you collect the result.
<sdschulze> In Lisp, you can "magically" construct the list.
<sdschulze> (Lists are mutable there, anyway, so it would be possible even in derived code.)
<sgnb> you can define your own mutable type of lists, that's not the point
<sdschulze> In the thread, Xavier points out that implementing List.map tail-recursively and without List.reverse is possible, but only using dark magic, and he doesn't want to do that.
awwaiid has quit [Ping timeout: 276 seconds]
<sgnb> if you want, you can define a list-like datatype that is mutable without resorting to dark magic
<sgnb> standard lists not being mutable is a feature IMHO
<sdschulze> Sure it is.
<sdschulze> Lists are very handy to abuse for a lot of stuff.
<sgnb> in lisp, there is basically no datatypes... everything is mutable lists (or maybe vectors)
<sgnb> but in ocaml, you can define your own datatype with quite some flexibility
<sgnb> you shouldn't think with a lisp mind there
<sdschulze> And functional languages often support them quite intimately.
<sgnb> more than functional, ocaml is also statically and strongly typed
<sdschulze> You mean immutable lists are a benefit for the programmer or for the compiler/run-time environment?
<sdschulze> Because this is a counter-example for the latter.
<sgnb> of course they are
<sdschulze> for both?
<sgnb> it's much easier to reason about and the runtime is optimized for that
listmap has joined #ocaml
<sgnb> as a general rule of thumb, mutating datastructures is evil
<listmap> sgnb: maybe it's evil but then evil is fast..
<sgnb> sometimes it is indeed... but not always
<sdschulze> The poison is sweet, at least.
<sgnb> and I prefer to write correct programs rather that fast ones
kingking has joined #ocaml
<sdschulze> It's what Java does. :)
<sgnb> Java uses mutable datatypes everywhere!
<sdschulze> sgnb: to reason about in terms of static analysis?
<sgnb> I was just thinking in terms of proof
<sdschulze> Shouldn't we all be using Haskell then?
<listmap> I'm curious - is there a general proof for the fact that using immutable data structures create more correct code?
<sgnb> don't get me wrong: I'm not against data being possibly mutable, I'm just glad they are not by default
<sgnb> (and Haskell seems a bit too much extremist for me... and too ugly syntax-wise)
<sgnb> listmap: what kind of proof do you expect
<sdschulze> The other option is: (* If you fiddle around with the internals of this data structure, God will kill a kitten!!!!! *)
<sgnb> program for some years in C, then in OCaml and you'll understand
<sdschulze> It still depends if you want to proof something by a machine or by a human.
<listmap> Been there done that. But my question was more Hashtbl vs Map in Ocaml
<sgnb> I was thinking about human proofs
<sgnb> and for Hashtbl vs Map, it depends on what you are doing
<sgnb> Map are more convenient (and probably efficient), if your data structure is changing a lot across recursive calls (for example)
<sdschulze> Hm, a cons cell is probably the most elegant data structure ever, but the question is if it's still the most realistic one today.
<sgnb> but I also often use Hashtbl when I only need to add things
<sgnb> a cons cell is like a functional void*
<sdschulze> I once got it trouble when I wanted to do mutually recursive data types with Map.
<listmap> I can't see the drawback of using Hashtbl instead of Map - only difference is that the GC will be working much more with Map, right? And add/remove in a Map is more stable.
<sdschulze> though PMap fixes it
<sdschulze> but you have to install Batteries
psnively has joined #ocaml
<sgnb> listmap: if you are writing a recursive evaluator for some language with variables, Map are much more fit than hashtables IMHO
<sgnb> with hashtables, you'd have to explicitly remove variables from the table when a variable goes out of scope, which is quite clumsy (and error-prone)
<sgnb> whereas with maps, it would just be "obviously" correct
<sdschulze> The main reason why I use objects and hashtables at all is mutual recursion.
<sgnb> sdschulze: do you have a concrete example? I didn't hear this argument before
<sdschulze> Wait, yeah.
<sdschulze> I even posted it here once, and got an answer -- but it seemed quite complicated.
<sdschulze> It's probably type inference that dictates that you must define a function/type/whatever before you can call it, right?
<sdschulze> Ordering up functions so they're declared in the right order has been the greatest PITA I've had so far with OCaml.
<sdschulze> I decided that in one module, I wanted to use some function from another module.
<sdschulze> didn't work, because the latter already used a function from the former module
<sdschulze> So I kinda had to abandon all my module structure.
dark has quit [Ping timeout: 265 seconds]
kingking has quit [Quit: http://irc2go.com/]
<sdschulze> That was one of the few times I wished I was using Java. ;)
<sgnb> sdschulze: what about something like http://paste.debian.net/80832/ ?
<sgnb> (but I must admit I didn't face myself such situation in real life)
<sdschulze> That's about what was suggested to me.
<sdschulze> But I just used a polymorphic hashtable. :)
<sdschulze> Are C-style pre-declarations so much impossible?
<sdschulze> of functions, that is
<sgnb> the explicit signature needed in recursive modules are kind of C-style pre-declarations, aren't they?
<sdschulze> So I should do that any time I want to do some strange kind of mutual recursion?
<sgnb> at least for class/module mutual recursions... but there are other "standard tricks" for other situations
<sdschulze> What about my other example above, with module structure interfering with call structure?
<sdschulze> (I think that's the difference between some people call "structural programming" vs. "modular programming". In structural programming, problems are slices down to smaller parts and functions are grouped abstract/special. In modular programming, functions are grouped in what kind of stuff they do. OOP is similar to the latter.)
psnively has quit [Quit: psnively]
dark has joined #ocaml
<krankkatze> hi
<krankkatze> hum, paste fail.
<krankkatze> Error: Unbound record field label tm_wday
<krankkatze> on an Unix.tm
<krankkatze> is this normal and what should I do?
ygrek has quit [Ping timeout: 245 seconds]
<adrien> krankkatze: you need to access the record with Unix.tm_wday unless you've 'open Unix' (but without the code, that's only a guess)
<krankkatze> it was it
<krankkatze> but I don't really understand why it is so
<adrien> because field names are local to modules: you can have the same name in different modules
<krankkatze> oh yeah
<krankkatze> this was stupid from me
<krankkatze> thanks
<adrien> :-)
<sgnb> you can also use Unix.(something using tm_wday) with 3.12
<ski> sgnb : hm, is that documented ?
<adrien> ski: should be, but it's only in 3.12 (or <= 3.11 with pa_open_in I think)
<sgnb> well... 3.12 is not released (yet)
LionMade0fLions has quit [Read error: Operation timed out]
|marius| has quit [Remote host closed the connection]
|marius| has joined #ocaml
|marius| has quit [Read error: Connection reset by peer]
|marius| has joined #ocaml
seafood has joined #ocaml
DaveS has joined #ocaml
Associat0r has quit [Quit: Associat0r]
listmap has quit [Quit: Page closed]
liftm has joined #ocaml
chee has quit [Ping timeout: 265 seconds]
|marius| has quit [Remote host closed the connection]