flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 4.00.1 http://bit.ly/UHeZyT | http://www.ocaml.org | Public logs at http://tunes.org/~nef/logs/ocaml/
tane has quit [Quit: Verlassend]
ollehar has quit [Ping timeout: 256 seconds]
Neros has quit [Ping timeout: 260 seconds]
eni has joined #ocaml
yacks has joined #ocaml
ollehar has joined #ocaml
yacks has quit [Ping timeout: 264 seconds]
yacks has joined #ocaml
ollehar has quit [Ping timeout: 276 seconds]
paolooo has joined #ocaml
eni has quit [Ping timeout: 256 seconds]
chrisdotcode_ has joined #ocaml
chrisdotcode has quit [Ping timeout: 252 seconds]
jtoman_ has left #ocaml []
chambart has joined #ocaml
Drup has quit [Quit: Leaving.]
Drup has joined #ocaml
paolooo has quit [Quit: Page closed]
madroach has quit [Ping timeout: 248 seconds]
madroach has joined #ocaml
dsheets has joined #ocaml
<bernardofpc> gasche> (and Euler problems are a particularly bad kind of toy problems if you ask me, as they rely on cunning maths rather than good code) -> well, a math guy would tell you that thinking about your math is what really makes algorithms faster ;-))
<bernardofpc> (as in lowering your O()-time)
<bernardofpc> (and also math guys like me would tell you that the constant *is* important if you want to get an answer today for tomorrow's forecast :D)
<bernardofpc> half-related, is there a nice profiler / profile tools for OCaml code ?
<bernardofpc> (added bonus if accessible from toplevel)
<bernardofpc> Drup: is gprof sufficient to native code ?
<Drup> I don't do profiling a lot, but when I do, it's enough for me.
<bernardofpc> right
<Drup> opam is telling me this : http://ocamlviz.forge.ocamlcore.org/, this looks nice.
q66 has quit [Remote host closed the connection]
darkf has joined #ocaml
<bernardofpc> hum, syntax question
<bernardofpc> let v = Array.make 1000 0
<bernardofpc> v.(0) <- 1 ; v.(1) <- 2
<bernardofpc> how do I put that in a compiled file ?
<bernardofpc> I'm getting a "Syntax error" in the first <-
<bernardofpc> (on the toplevel I finish with ";;", but I thought that was not needed in .ml files)
<Drup> this is not needed if your file contains only declaration
<Drup> (the ocaml grammar is a bit messy about this ...)
<Drup> do this : let _ = my () ; sequential () ; stuff ()
<bernardofpc> Drup: these are the "top" lines of the code, I use the vector v in some functions "below"
<bernardofpc> (I guess this has to be below)
<bernardofpc> I tried ";" all the time, but I did not think Array.make was a "sequential" instruction
eikke has joined #ocaml
<Drup> pastebin the code plz.
<bernardofpc> ok
<Drup> bernardofpc: you don't have to make it look nice, just pastebin it :D
<bernardofpc> I'm double-checking my ";"
<bernardofpc> it says
<Drup> so that's basically what I said
<bernardofpc> line 3, characters 6-8:
<bernardofpc> Error: Syntax error
<Drup> let _ = v.(0) <- 1 ; v.(1) <- 2
<bernardofpc> ugh
<bernardofpc> this is supposed to "type" as a unit , that's why it needs to be bound to something ?
<Drup> there is no "need", you could put ;; everywhere and it will work
<bernardofpc> (I'd never thought of that, that's why I didn't even understant your first suggestions...)
<Drup> well, you're doing the exact same thing at the end of the file
<bernardofpc> what's the real meaning of ";;" ?
<Drup> "end of the phrase"
<bernardofpc> hum
<bernardofpc> so something like "let a = 3*4" is not a finished phrase ?
<Drup> in general, no
eikke has quit [Ping timeout: 260 seconds]
<Drup> you could end the line and add " +2" after
<Drup> caml is not whitespace sensitive
<bernardofpc> thanks goodness
<bernardofpc> so in fact all my previous programs (without ";;") had a *single* phrase ?
<Drup> but when there is a "let" after "let a = 3*4", the parser now the phrase is finished
<bernardofpc> ah
<bernardofpc> what's a phrase, then ?
<LiesHidden> I think xelpaste has more support than ideone does lol
<Drup> sentence* because I'm french and tired :3
<bernardofpc> Drup: ok, I'll ask tomorrow
<bernardofpc> (I was looking more for a definition of phrase as built of "expressions" and some other stuff I might not know)
<Drup> bernardofpc: it's just a parser thingy, it's not very important
<LiesHidden> I'd say that ';;" means end of expression.
<bernardofpc> well, it's important for me, because it got me confused
ontologiae has joined #ocaml
<Drup> bernardofpc: oh, you're not the first ocaml beginner to be confused by this stupid parsing thing, it's a really confusing one
<bernardofpc> :/
<LiesHidden> Personally, I've just got into the habit of using ';;' after every expression, even known they're not required if the next line starts with 'let' or what not.
<Drup> bernardofpc: the solution is simple but never really explained : every .ml file is a sequence of let bindings and that's all.
<Drup> and when you do that, you don't need ;; anymore
<bernardofpc> right
<bernardofpc> but it does not seem right to do let _ = BLAH for a sequential statement
<bernardofpc> I'd rather use "let" for bindings and ; for sequencing
<Drup> the semantic of "let _ = stuff ()" is "do stuff and then throw away the result"
<bernardofpc> sure
<Drup> so that basically what you want.
<bernardofpc> but I find it a bit convoluted to say "do stuff" with "let _ = stuff"
<Drup> stuff ()*
<Cypi> I prefer "let () = stuff ()"
<bernardofpc> whereas "stuff () ; " is more convincing of the sequencing nature of it
<bernardofpc> (of course, let () = stuff () is also sequential, but only because OCaml enforces textual order in its value definitions)
<Drup> bernardofpc: ";" is not the "end of a sequence, it's the seperator of operations, that's not exactly the same
eikke has joined #ocaml
<bernardofpc> right
<Drup> Cypi: yeah, I do agree it's probably safer
<bernardofpc> the quesiton is then why OCaml's parser does not know that "let v = Array.make 1000 0" is finished
<Drup> because it's not ?
<bernardofpc> well, it sure knows that the let-binding is complete, doesn't it ?
<Drup> but no, it's not
<bernardofpc> Array.make takes two arguments, they're all there, what else could there be ?
<Drup> let say I have defined this operator :
<Drup> let (|>) x f = f x
<bernardofpc> oh
<Drup> I can add after Array.make the call to this pipe operator and go on
<bernardofpc> right, infix mess
<Drup> another thing
<Drup> the fact that this call is "complete" as you say is know when analyzing and typing the code
<Drup> the error you had is a parsing error
<Drup> it's not a all done in the same moment.
<Drup> at*
<bernardofpc> I see
<bernardofpc> it's a bit sad, though
<bernardofpc> (but probably safer) not to mix parser with semantics analysis
<Drup> it's hard to do semantics analysis without parsing before :D
oriba_ has quit [Quit: oriba_]
<Drup> (to be honest, I like my ocaml with this lack of whitespace awareness, you can arrange the code in the most sensible way according to what you're doing
gnuvince has joined #ocaml
chrisdotcode_ has quit [Ping timeout: 246 seconds]
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
ontologiae has quit [Ping timeout: 252 seconds]
chambart has quit [Ping timeout: 264 seconds]
eikke has quit [Read error: Operation timed out]
dsheets has quit [Ping timeout: 256 seconds]
osnr has quit [Quit: Leaving.]
mattrepl has quit [Quit: mattrepl]
Watcher7 is now known as Watcher7|off
derek_c has quit [Ping timeout: 246 seconds]
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
emmanuelux has quit [Quit: emmanuelux]
osnr has quit [Quit: Leaving.]
Zeev has quit [Read error: Connection reset by peer]
rwmjones has quit [Read error: Operation timed out]
es917 has joined #ocaml
justdit has joined #ocaml
alang__ has joined #ocaml
justdit has quit [Quit: Lost terminal]
rwmjones has joined #ocaml
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
gnuvince has quit [Ping timeout: 245 seconds]
derek_c has joined #ocaml
gautamc has quit [Read error: Connection reset by peer]
gautamc has joined #ocaml
Zeev has joined #ocaml
ben_zen has joined #ocaml
Watcher7|off is now known as Watcher7
asmanur has quit [Ping timeout: 240 seconds]
asmanur has joined #ocaml
jcao219 has quit [Ping timeout: 248 seconds]
Drup has quit [Quit: Leaving.]
<rgrinberg> bernardofpc: you might like ocaml-twt
yezariaely has quit [*.net *.split]
olasd has quit [*.net *.split]
j0sh has quit [*.net *.split]
samebchase has quit [*.net *.split]
fds has quit [*.net *.split]
Asmadeus has quit [*.net *.split]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
olasd has joined #ocaml
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
samebchase has joined #ocaml
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
j0sh has joined #ocaml
fds has joined #ocaml
Asmadeus has joined #ocaml
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
fds_ has joined #ocaml
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
j0sh has quit [*.net *.split]
fds has quit [*.net *.split]
Asmadeus has quit [*.net *.split]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
t4nk293 has quit [Ping timeout: 250 seconds]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
j0sh has joined #ocaml
Asmadeus has joined #ocaml
yezariaely has joined #ocaml
yezariaely has quit [Max SendQ exceeded]
yezariaely has joined #ocaml
cdidd has joined #ocaml
<adrien> yezariaely: you need to fix your connection and/or client
<adrien> yezariaely: your client might be flooding the servers upon reconnection
ben_zen has quit [Quit: Wheeeeee]
fds_ is now known as fds
osnr has quit [Quit: Leaving.]
Yoric has joined #ocaml
ygrek has joined #ocaml
ttamttam has joined #ocaml
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
ygrek has quit [Ping timeout: 256 seconds]
Watcher7 is now known as Watcher7|off
* adrien has one hour to code a trivial feature, in javascript; let's start the bet
ulfdoz has joined #ocaml
<darkf> bet on what
Snark has joined #ocaml
<adrien> whether one hour will be enough
<darkf> ah, lol
<darkf> what's the feature?
<adrien> usually it isn't and I have the feeling I've lost a lot of time with JS
<adrien> I have dropdown lists and according to the value selected, I filter an in-memory data structure
<adrien> I need to add "Any" to the dropdown lists
Tobu has joined #ocaml
ggole has joined #ocaml
osnr has quit [Quit: Leaving.]
eni has joined #ocaml
derek_c has quit [Quit: Lost terminal]
ttamttam has quit [Ping timeout: 245 seconds]
justdit has joined #ocaml
Kakadu has joined #ocaml
ollehar has joined #ocaml
<adrien> done :P
<adrien> so roughly 40 minutes actually spent on that (or maybe a bit more)
justdit has quit [Quit: Lost terminal]
<adrien> but it's always annoying, painful and it surely takes more time than it should
ttamttam has joined #ocaml
ttamttam has quit [Ping timeout: 240 seconds]
Neros has joined #ocaml
Fnar has quit [Ping timeout: 264 seconds]
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
ygrek has joined #ocaml
osnr has quit [Ping timeout: 256 seconds]
letrec has quit [Ping timeout: 260 seconds]
ygrek has quit [Ping timeout: 276 seconds]
bacam has quit [Quit: reboot]
bacam has joined #ocaml
ttamttam has joined #ocaml
chambart has joined #ocaml
ygrek has joined #ocaml
everyonemines has joined #ocaml
ulfdoz has quit [Ping timeout: 264 seconds]
Yoric has quit [Ping timeout: 260 seconds]
Fnar has joined #ocaml
q66_ has joined #ocaml
q66_ is now known as q66
talzeus has joined #ocaml
ontologiae has joined #ocaml
justdit has joined #ocaml
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
osnr has quit [Ping timeout: 256 seconds]
Yoric has joined #ocaml
t4nk273 has joined #ocaml
<t4nk273> is (let _ = print_string "some string" in fxn x y z);; preferred over (print_string "some string"; fxn x y z);;
<Kakadu> no
<t4nk273> ok
<Kakadu> in standart syntax - no
<t4nk273> other way around?
<Kakadu> you can write let () to be more revised-compatible, but I don't understand why your 2nd variant is bad
<t4nk273> actually ive been using 2nd variant but i see some code using the first variant
<ggole> It's just so you don't need to stick ;;s after everything
<t4nk273> ic
<ggole> Usually you wouldn't use in though, since it's not there for binding
<ousado> adrien: still not using js_of_ocaml?
oriba has joined #ocaml
ygrek has quit [Quit: ygrek]
<t4nk273> ic
<Kakadu> ousado: It's not so fantastic how it looks like
<ousado> what?
<ousado> js_of_ocaml?
<Kakadu> ousadoL yep
<ousado> well, I think the mistake you're making is to compare it with ocaml. but you really haveto compare it with JS
eni has quit [Ping timeout: 252 seconds]
<ousado> you still have to be aware of some stuff etc, but really.. the toplevel works in the browser, how much more can you expect
<Kakadu> I only want to say that it's integeration with server code is a little bit inconvenient
<ousado> you mean eliom then
<Kakadu> yep
<ousado> hm.. in what way inconvenient?
<Kakadu> probably with example it will be better
<Kakadu> lets we have users on a website and one can subscribe on news of another
<Kakadu> and if vice versa than they are "mutal friends"
jbrown has joined #ocaml
<Kakadu> I want a button on user info page with three states: Subscribed with onclick handler, 'You are subscribed' label and 'You r mutal' label
<Kakadu> s/Subscrbed/Subscribe/
<Kakadu> I can't find convenient way to add this onclick handler and operate with div's content in this
<Kakadu> If we have three kind of divs...
<Kakadu> 1. div ~a:[a_onclick onclicked] [pcdata "Subscribe"]
<Kakadu> 2. div [pcdata "you r subscribed"]
<Kakadu> 3. div [pcdata "mutal"]
<Kakadu> I can't you created div in onclicked because if I write
<Kakadu> let rec onclicked = {mouseEvent Js.t->unit{ ...... }} and d = div ~a:[a_onclick onclicked] [pcdata "Subscribe"]
<Kakadu> It will not compile because onclicked is not a function
<Kakadu> onclicked has become a funtion which return client function
<Kakadu> but now it raises exception after last statement of this client onclick and I have no idea why does it happend and where shoudl I put try...with
<Kakadu> I will be very glad if client functions will become really functions
<Kakadu> ousado: I finished:)
ttamttam has left #ocaml []
ygrek has joined #ocaml
<ousado> Kakadu: actually I think you're asking for a too tight level of integration
<Kakadu> ousado: I think that without it a part of expressivity dissapears
<ousado> it's a performance issue if a sinlge function of 5 lines requires 4 full roundtrips between client and server
<ousado> which could easily happen
<ousado> also if the server values are shared between clients, they have to be synchronized somehow
<ousado> and security might be an issue
<ousado> you really want a well-defined interface for passing data between client and server
<Kakadu> What do u mean?
<ousado> which part?
<Kakadu> about sharing and security. I haven't understanded yet how it is related to my previous story
<ousado> well, if every value is easily available to the peer by advanced magic, it's easy to share the wrong data
chambart has quit [Ping timeout: 240 seconds]
<ousado> think of some cipher, a private key or whatever
<Kakadu> You want to say that eliom trys to defend me from myself by inconvenient syntax?
<Kakadu> </troll> :)
<ousado> no I think it goes a looong way to provide convenient tools to exchange data
justdit has quit [Read error: Connection reset by peer]
<ousado> in your above example, for instance, I think there should be a few functions exposed: subscribe_to_user accept_user, unsubscribe etc.
<ousado> a "click" is a client-side thing
<Kakadu> I have almost the same
<ousado> and for anything non-trivial you want to handle user-interaction client-side and communicate the *results* to the server
<ousado> like fill a form <-> validation feedback -> captcha -> confirm -> whatever and *then* post
<ousado> you don't have to expose a divs onclick-handler for that
mcclurmc has quit [Ping timeout: 245 seconds]
ygrek has quit [Ping timeout: 256 seconds]
eikke has joined #ocaml
ttamttam has joined #ocaml
gautamc has quit [Read error: Connection reset by peer]
gautamc has joined #ocaml
ontologiae has quit [Ping timeout: 252 seconds]
justdit has joined #ocaml
ollehar has quit [Ping timeout: 245 seconds]
himito has joined #ocaml
<himito> Bonjour / Hello / Hola
ollehar has joined #ocaml
Drup has joined #ocaml
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
Yoric has quit [Ping timeout: 264 seconds]
ttamttam has left #ocaml []
<Kakadu> hey
mattrepl has joined #ocaml
<Kakadu> ousado: Btw, do you know an example with optional service paramters and forms? I don't know how to express None in form field....
osnr has quit [Ping timeout: 264 seconds]
Drup has quit [Quit: Leaving.]
justdit has quit [Quit: Lost terminal]
Drup has joined #ocaml
justdit has joined #ocaml
justdit has quit [Quit: Lost terminal]
Drup has quit [Ping timeout: 252 seconds]
ontologiae has joined #ocaml
eikke has quit [Ping timeout: 264 seconds]
Drup has joined #ocaml
ben_zen has joined #ocaml
emmanuelux has joined #ocaml
justdit has joined #ocaml
justdit has quit [Client Quit]
dsheets has joined #ocaml
TaXules_ is now known as TaXules
ontologiae has quit [Ping timeout: 276 seconds]
eikke has joined #ocaml
ygrek has joined #ocaml
SanderM has joined #ocaml
Yoric has joined #ocaml
breakds has joined #ocaml
ben_zen has quit [Ping timeout: 276 seconds]
letrec has joined #ocaml
SanderM_ has joined #ocaml
SanderM has quit [Ping timeout: 264 seconds]
<foo303> let rec readlines = try (input_line stdin)::readlines with End_of_file -> [];;
<foo303> Why does this not work exactly?
<adrien> well, how does the compiler complain?
<foo303> Error: This kind of expression is not allowed as right-hand side of `let rec'
<foo303> and highlights the entire part after the =
<adrien> hmm, right, that's not the most explicit message...
<foo303> heh :p
<foo303> "you can't do that" is equally useful in this case
<adrien> according to you, what would be the type of "readlines"?
<foo303> I want it to be string list
<foo303> which is what I assumed should be inferred, as its elements are made from (input_line stdin)
<adrien> how would the code be evaluated?
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
<foo303> it would get (input_line stdin) then append that to the list made from readlines.
<foo303> and readlines would do the same, until End_of_file is raised, so the last call would be (input_line stdin)::[]
<adrien> what would be the initial value of readlines?
<foo303> oh, is it appending a string to a function in this case?
<foo303> (which is not allowed)
ygrek has quit [Remote host closed the connection]
walter|rtn has joined #ocaml
ygrek has joined #ocaml
<adrien> well, readlines here cannot be a function
<adrien> the right-side is of type string list so readlines itself would be string list
tane has joined #ocaml
<adrien> also, it's not appending but prepending here
<ggole> let rec readlines () = try (input_line stdin)::readlines () with End_of_file -> []
<foo303> let rec readlines () = try (input_line stdin)::(readlines ()) with End_of_file -> []
<ggole> Do note that this is *not* tail recursive.
walter|r has quit [Ping timeout: 248 seconds]
osnr has quit [Ping timeout: 252 seconds]
<foo303> # readlines();;
<foo303> Stack overflow during evaluation (looping recursion?).
ontologiae has joined #ocaml
<adrien> depend on the length of the file: above 130k lines you'll crash
<foo303> actually, that's without adding any lines. just in the interpreter and without any noticable waiting time, it overflowed
<adrien> the initial issue was that the definition of readline was pretty much infinite
<adrien> that the execution is is another matter
<foo303> so how can I tame the definition?
<foo303> I want to read all lines, put them in a list
<adrien> with readlines as a function it's fine
<adrien> hmmm, it probably evaluates (readlines ()) before (input_line stdin) :-)
<adrien> you can simply split that line in two steps
<ggole> Oh, yeah
<foo303> so if I say "let rec readlines () = (function () -> body)" vs. "let rec readlines () -> body" it differs? I mean, the first is unit -> unit -> string list whereas the second is unit -> string list, but I'm not so sure why they're different
<adrien> hmm, the first one doesn't look like a very interesting thing to do
<adrien> you'll have to call (readlines ()) would return a function of type unit -> string list that you would have to call with () in order to trigger any work
<adrien> return a function has uses but not really here
<foo303> right, I was hoping to force a "delay" so to speak
<foo303> (I am not actually sure why it caused the stack to overflow right off the bat with no lines read)
<adrien> (a :: b) needs to build b first
<adrien> but if you let a = foo () in a :: b
<foo303> ohhh, damn. sml doesn't do this
<adrien> (actually I'm not sure (a :: b) _needs_ to build b first; I guess the order is simply unspecified)
<Drup> adrien: why is that ? isn't the evaluation order usualy left to right ?
<ggole> Ocaml seems to eval right to left for some reason
<Drup> except for logical operators
<adrien> Drup: unspedified and iirc it changes depending on whether you're using bytecode or native code
<adrien> or it used to
<ggole> I think for a proper tail-recursive readlines you have a write a stupid loop, something like let rec readlines () = let rec loop acc = let acc', more = try input_line stdin::acc, true with End_of_file -> acc, false in if more then loop acc' else acc' in loop []
<Drup> adrien: ok
<ggole> You have to avoid guarding the recursive call with try, otherwise it will not tail recurse
<adrien> ggole: why the bool?
<adrien> ah, right; had forgotten that
<ggole> How can you tell whether to make the call or not otherwise?
<ggole> It's either that or a ref :)
<ggole> I/O is unfortunately quite clumsy in OCaml
gustav_ has joined #ocaml
<ggole> Again, not tail recursive: and I believe it will fail if there is not at least one line.
breakds has quit [Quit: Konversation terminated!]
<foo303> right. in the case where there is no line, End_of_file shows up at the top
Drup has quit [Remote host closed the connection]
Drup has joined #ocaml
<foo303> it would've been nice if I didn't have to List.rev after all this
jbrown has quit [Remote host closed the connection]
<foo303> either I will be appending lists to lists, or reversing the result, but prepending items to the same list
<orbitz> Core makes I/O a litlte less clumsy IMO
<ggole> Maybe you want a vector
<ggole> Or DynArray, or whatever batteries calls them
<foo303> I'm just starting out with caml, so, Core and DynArray. I'll check them out.
<foo303> thanks.
<foo303> orbitz: I found BatDynArray, but what is Core?
ygrek has quit [Ping timeout: 246 seconds]
<foo303> oh. nevermind. googling was not as good as opaming
<ggole> Core is jane st's extension to the stdlib
<foo303> one question about ocaml in general. Some people told me ocaml has a global lock, when it comes to threads. Is there any practical way to go around this that doesn't make builds horrible for others?
<ggole> Sadly the GC is not designed to handle concurrent threads
<ggole> So the lock is necessary
darkf has quit [Quit: Leaving]
<foo303> sexplib is a dependency of core. must be good.
talzeus has quit [Remote host closed the connection]
bernardofpc has quit [Quit: leaving]
bernardofpc has joined #ocaml
bernardofpc has quit [Client Quit]
bernardofpc has joined #ocaml
letrec has quit [Ping timeout: 276 seconds]
mcclurmc has joined #ocaml
ontologiae has quit [Ping timeout: 276 seconds]
eikke has quit [Ping timeout: 256 seconds]
eikke has joined #ocaml
walter|rtn has quit [Read error: Connection reset by peer]
walter has joined #ocaml
ttamttam has joined #ocaml
tane has quit [Quit: Verlassend]
ulfdoz has joined #ocaml
<flux> foo303, in practice you can only run C code in parallel
<flux> foo303, or, alternatively, you can run multiple ocaml processes
<flux> which doesn't need to be that bad if your problem fits into (say) parallel map
ttamttam has left #ocaml []
jbrown has joined #ocaml
SanderM_ has quit [Remote host closed the connection]
breakds has joined #ocaml
weie has quit [Quit: Leaving...]
eni has joined #ocaml
ollehar has quit [Ping timeout: 256 seconds]
* dsheets dons flame retardant suit.
Watcher7|off is now known as Watcher7
weie has joined #ocaml
gnuvince has joined #ocaml
pkrnj has joined #ocaml
LiesHidden has left #ocaml []
ggole has quit [Ping timeout: 245 seconds]
ollehar has joined #ocaml
ygrek has joined #ocaml
ggole has joined #ocaml
transfinite has joined #ocaml
ttamttam has joined #ocaml
oriba has quit [Quit: oriba]
ontologiae has joined #ocaml
tane has joined #ocaml
ttamttam has left #ocaml []
pkrnj has quit [Ping timeout: 245 seconds]
ollehar has quit [Ping timeout: 252 seconds]
ollehar has joined #ocaml
Snark has quit [Quit: leaving]
yacks has quit [Quit: Leaving]
breakds has quit [Remote host closed the connection]
ben_zen has joined #ocaml
<pippijn> let filter_valid = List.filter (not ∘ List.∃ Ops.is_empty_language)
<pippijn> :)
<adrien> Error: Illegal character (\136)
<adrien> ='(
<pippijn> let filter_valid = List.filter (not -| List.exists Ops.is_empty_language)
Kakadu has quit [Ping timeout: 248 seconds]
ontologiae has quit [Ping timeout: 276 seconds]
ygrek has quit [Ping timeout: 248 seconds]
ollehar has quit [Ping timeout: 245 seconds]
contempt has quit [Ping timeout: 248 seconds]
contempt has joined #ocaml
tobiasBora has joined #ocaml
<tobiasBora> Hello,
<tobiasBora> I've a question : when I run Printf.print, I've sometimes a time lag between I call it and I print it and it's very annoying...
<tobiasBora> Could I disable thie behaviour ?
<adrien> hmmm
<adrien> can you be more specific?
<adrien> ah
<adrien> the output is buffered I guess
<adrien> append %! to your format string
<adrien> it'll make the output be flushed
<tobiasBora> adrien: maybe.. Where could I put it ?
<tobiasBora> at the beginning ?
<adrien> where you want the output to be flushed
<adrien> typically it's at the end of the format string
<adrien> mine usually look like "foobarbaz\n%!"
<tobiasBora> adrien: when you tell "flushed" you mean print on the output ?
<adrien> have it appear on screen, yes
Watcher7 is now known as Watcher7|off
Kakadu has joined #ocaml
<tobiasBora> adrien: Great it works perfectly !!! Thanks a lot ! And is it possible to make this behaviour happend for each Printf.printf automatiquely ? And when it's buffered, where does he display the output on screen ?
Zeev has quit [Ping timeout: 248 seconds]