psnively has quit [Read error: 104 (Connection reset by peer)]
psnively has joined #ocaml
svenl has quit [Remote closed the connection]
svenl has joined #ocaml
optikalmouse has joined #ocaml
<optikalmouse>
I need some help with multiple statements in an else block
tehdeuce has left #ocaml []
<optikalmouse>
if ... then ... else printf "%f %f" i fn (i); recurse;;
<optikalmouse>
it's telling me that the printf call is incorrect :(
<optikalmouse>
anyone alive?
<psnively>
optikalmouse: ruminating, sorry.
<psnively>
What is the exact error?
<optikalmouse>
too many units
<psnively>
My immediate reaction is to parenthesize fn (i).
<psnively>
printf "%f %f" i (fn i);
<optikalmouse>
ok cool
<psnively>
Incidentally, in OCaml, you don't need to parenthesize arguments to functions unless the context is ambiguous.
<optikalmouse>
now I think it's leaving the return value of (fn i) as unit
<optikalmouse>
which is mismatched with the %f I have (obviously)
<psnively>
Well, you should have a look at fn, then.
<psnively>
Right.
<optikalmouse>
but fn is being passed in...it's a function type
<optikalmouse>
which takes in a float and returns a float
<psnively>
Hmmm.
<psnively>
So you still get the error after parenthesizing (fn i)?
<optikalmouse>
different error now
<optikalmouse>
This expression has type unit but is here used with type float
<psnively>
Aha!
<optikalmouse>
Aha?
<psnively>
Either i or (fn i) is of type unit.
<psnively>
Which one should be underlined in your terminal.
<psnively>
Here's what I just did, in the "ocaml" toploop:
<psnively>
open Printf;;
<psnively>
Printf.printf "%f %f" 3.4 ();;
<psnively>
And it said:
<psnively>
This expression has type unit but is here used with type float
<psnively>
And the "()" was underlined.
<psnively>
As it should be.
<optikalmouse>
ah ok
<optikalmouse>
I'm writing this in a file heh
<psnively>
That's fine. Just run "ocaml" and #use "the_file.ml";;
<psnively>
Better yet, use EMACS and Tuareg Mode, and evaluate expressions as you type them in.
<optikalmouse>
ok, use is unbound.
<psnively>
Sorry: include the "#".
<optikalmouse>
ahh ok
<optikalmouse>
I thought that was part of the REPL
<psnively>
Yeah, I can see that. But directives in the ocaml toploop begin with "#".
<psnively>
So unfortunately, the line on the screen looks like: # #use "foo.ml";;
<psnively>
But really, you're going to be much more productive in EMACS with either OCaml Mode or Tuareg Mode.
<optikalmouse>
I'll grab it later...I'm also hacking at some Python and C++ code :S
<optikalmouse>
thanks for the help :D
<psnively>
Anytime!
optikalmouse has left #ocaml []
zarul has quit [Connection timed out]
Mr_Awesome has joined #ocaml
<mbishop>
emacs will help with the python and C++ code too :P
<psnively>
The operating system thinly disguised as a text editor...
seafoodX has joined #ocaml
psnively has quit [Read error: 104 (Connection reset by peer)]
psnively has joined #ocaml
psnively has quit [Client Quit]
chs_ has quit []
<tsuyoshi>
ok so this dbacl could be used for images if you can appropriately tokenize it
<tsuyoshi>
wonder if you could just.. give it a dct in some form
fluctus has joined #ocaml
Modius has quit []
pants1 has quit [Read error: 104 (Connection reset by peer)]
pants1 has joined #ocaml
pants1 has quit [Read error: 104 (Connection reset by peer)]
_blackdog has joined #ocaml
_blackdog has left #ocaml []
gim_ has quit [Remote closed the connection]
bluestorm_ has joined #ocaml
putpixel has joined #ocaml
putpixel has left #ocaml []
putpixel has joined #ocaml
putpixel has left #ocaml []
bluestorm_ has quit [Remote closed the connection]
tree has quit [Read error: 110 (Connection timed out)]
pango has joined #ocaml
pango has quit [Excess Flood]
pango has joined #ocaml
love-pingoo has joined #ocaml
Submarine has quit ["in Soviet Russia, Céline Dion owns you"]
pango_ has quit [Remote closed the connection]
Mr_Awesome has quit ["time to impregnate a moth"]
G has joined #ocaml
seafoodX has quit []
smimou has joined #ocaml
mikeX has joined #ocaml
jlouis_ has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
jlouis has quit [Read error: 110 (Connection timed out)]
<love-pingoo>
mmm, how do you flush a Unix.file_descr
<love-pingoo>
Unix.tcflush seems weird
<love-pingoo>
I use it on an output pipe with TCOFLUSH, I get EINVAL
<rwmjones>
isn't there a Unix.flush call?
* rwmjones
checks
<love-pingoo>
nope
<rwmjones>
hang on, you don't need to flush a Unix file_descr
<rwmjones>
they just correspond directly to underlying fds
<love-pingoo>
yeah possibly, I don't know
<love-pingoo>
I opened an external program (create_process) and i'm trying to communicate with it through pipes
<love-pingoo>
for example, I now communicate with cat, I write data in but I don't get anything out
<love-pingoo>
something else might be wrong
<rwmjones>
yeah, that's never going to work
<rwmjones>
because you get a deadlock
<rwmjones>
unless you use Unix.select very carefully
<rwmjones>
also, "cat" internally buffers data, so it doesn't necessarily write out immediately after it has read something in
<love-pingoo>
deadlock ?
<love-pingoo>
I have two pipes, one for input one for output.
<rwmjones>
sure, but what happens if you try to write, and cat tries to write at the same time? you'll get deadlock
<rwmjones>
the guy who wrote cat works for Red Hat, I've just pinged him to see if there's a way to make it use line buffering, but I don't think there is if the man page is up to date
<love-pingoo>
cat writes to its output pipe, on which I only read
<love-pingoo>
and conversely, it only reads on its input pipe, on which I only write
<love-pingoo>
but the buffering might be the reason for not getting any output
<rwmjones>
are you using Unix.select in the main program? if not you'll get deadlock. Try stracing both processes to see what I mean.
<love-pingoo>
I was trying with ocaml and another interpreter of mine too, didn't work either
<love-pingoo>
I'm using Tk fileevent thingy, which probably relies on select, yes
<love-pingoo>
I'll try something without Tk first...
<love-pingoo>
works fine, using select on stdin and process output
<love-pingoo>
okay I was being stupid, didn't pass the right handle to Tk
<love-pingoo>
it's always like that
gim_ has joined #ocaml
schme has joined #ocaml
zarul has joined #ocaml
tty56 has joined #ocaml
_blackdog has joined #ocaml
_blackdog has left #ocaml []
tty56_ has quit [Read error: 113 (No route to host)]
zarul has quit [Read error: 113 (No route to host)]
ramkrsna has quit ["Leaving"]
ygrek has joined #ocaml
THC4k has joined #ocaml
LeCamarade has joined #ocaml
schme` has joined #ocaml
leo037 has joined #ocaml
schme has quit [Connection timed out]
LeCamarade has quit [Read error: 110 (Connection timed out)]
oxylin has joined #ocaml
zarul has joined #ocaml
kelaouch1 has quit ["leaving"]
cjeris has joined #ocaml
oxylin has quit ["Ex-Chat"]
edwardk has joined #ocaml
G_ has joined #ocaml
pango has quit [Remote closed the connection]
Submarine has joined #ocaml
pango has joined #ocaml
edwardk has quit [Remote closed the connection]
edwardk has joined #ocaml
G has quit [Connection timed out]
DirkT has joined #ocaml
LeCamarade has joined #ocaml
pango has quit [Remote closed the connection]
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
pango has joined #ocaml
gim__ has joined #ocaml
gim__ has quit [Read error: 104 (Connection reset by peer)]
gim_ has quit [Read error: 110 (Connection timed out)]
gim__ has joined #ocaml
psnively has joined #ocaml
visage has joined #ocaml
gim__ has quit []
_blackdog_ has joined #ocaml
_blackdog_ has left #ocaml []
tcr has joined #ocaml
<tcr>
I'm wondering if there's a polymorphic to_string function in ocaml? Something similiar to Haskell's `show'.
<rwmjones>
tcr, no there isn't, but you could use something like Std.dump from extlib
<psnively>
There's also Oleg K.'s generic print for MetaOcaml.
danly has quit [Read error: 110 (Connection timed out)]
leo037 has quit ["Leaving"]
DirkT has left #ocaml []
screwt8 has quit [Read error: 104 (Connection reset by peer)]
smimou has joined #ocaml
danly has joined #ocaml
Mr_Awesome has joined #ocaml
edwardk has left #ocaml []
LeCamarade has quit [Read error: 113 (No route to host)]
kipi has joined #ocaml
<kipi>
what is the entry point for a compiled ocaml program?
<rwmjones>
kipi, do you mean a standalone one, or one which is linked into C ?
<kipi>
standalone
<kipi>
i have a program with a couple of ml files and it seems to be executing the last function of the first one and the code not in a function of the second
<rwmjones>
all toplevel expressions are executed, in module link order
<rwmjones>
there is no "main()" function
<kipi>
aha
ygrek has quit [Remote closed the connection]
<kipi>
are function definitions classed as "top level"? i can't stop one of my functions executing, despite the fact it is not called from top level code
<rwmjones>
kipi, functions may be defined at the top level, but they are not automatically executed
<rwmjones>
let f () = ... ;;
<rwmjones>
is a toplevel function definition
<rwmjones>
as is:
<rwmjones>
let f = fun () -> ... ;;
<rwmjones>
but
<kipi>
kk
<rwmjones>
let a = ... ;;;
<rwmjones>
let a = ... ;;
<rwmjones>
defines a and the definition runs immediately
<rwmjones>
also,
<rwmjones>
let a = f () ;;
<rwmjones>
will run f () because it is needed to define a
<kipi>
ahh
<kipi>
that'll be it then
<rwmjones>
also the strange expressions:
<rwmjones>
let _ = ... ;;
<rwmjones>
and
<rwmjones>
let () = ... ;;
<rwmjones>
that you will see in OCaml code a lot, they run immediately
<kipi>
righto
<kipi>
so, i want () after the name, if it takes no arguments and i don't want it to execute immediately?
<rwmjones>
that's right
<kipi>
cool, thanks
<rwmjones>
() is actually a single parameter ... all functions in OCaml must take at least one parameter
<kipi>
aha
<rwmjones>
for example, this is valid (if not useless) code:
<psnively>
() is the single value of type unit.
<rwmjones>
let f () () = print_endline "hello";;
<rwmjones>
f takes two parameters, both of type unit
schme`` has joined #ocaml
schme` has quit [Connection timed out]
Modius has joined #ocaml
rwmjones has quit ["Closed connection"]
mikeX has quit ["leaving"]
leo037 has joined #ocaml
kelaouchi has joined #ocaml
kelaouchi has quit ["leaving"]
kelaouchi has joined #ocaml
visage has quit []
jlouis_ has quit [Remote closed the connection]
jlouis has joined #ocaml
_blackdog has joined #ocaml
jlouis_ has joined #ocaml
jlouis has quit [Read error: 104 (Connection reset by peer)]
kelaouchi has quit [Read error: 104 (Connection reset by peer)]
jlouis_ has quit [Client Quit]
_blackdog has quit [Remote closed the connection]
_blackdog has joined #ocaml
_blackdog has left #ocaml []
jlouis has joined #ocaml
gene9 has joined #ocaml
gene9 has quit [Read error: 104 (Connection reset by peer)]
gene9 has joined #ocaml
descender has quit ["Elegance has the disadvantage that hard work is needed to achieve it and a good education to appreciate it. - E. W. Dijkstra"]
gene9 has quit ["Leaving"]
zarvok has joined #ocaml
kelaouchi has joined #ocaml
<pango>
nethack popularity is falling down too :'(
screwt8 has joined #ocaml
<pango>
sorry, ECHAN
love-pingoo has quit ["je suis un gros geek"]
cjeris has quit [Read error: 104 (Connection reset by peer)]
tcr has quit ["Leaving."]
benny has joined #ocaml
benny_ has quit [Read error: 110 (Connection timed out)]
schme`` has quit [Connection timed out]
zarulshahrin_ has joined #ocaml
zarulshahrin__ has joined #ocaml
zarul has quit [Nick collision from services.]
zarulshahrin__ has quit [Client Quit]
zarulshahrin__ has joined #ocaml
zarulshahrin__ is now known as zarul
zarul has quit [Client Quit]
zarul has joined #ocaml
zarul has quit [Read error: 104 (Connection reset by peer)]
zarul has joined #ocaml
zarulshahrin__ has joined #ocaml
visage has joined #ocaml
lde has quit [Success]
zarulshahrin_ has quit [Read error: 110 (Connection timed out)]
smimou has quit ["bli"]
leo037 has quit ["Leaving"]
zarul has quit [Connection timed out]
zarulshahrin__ has quit [Connection timed out]
THC4k has quit [Read error: 104 (Connection reset by peer)]