sponge45 changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
Jessehk has joined #ocaml
<Jessehk>
I know this sounds stupid, but how can I convert from a char to a string?
<malc_>
# let s = String.create 1 in String.unsafe_set s 0 'a'; s;;
<malc_>
- : string = "a"
<malc_>
or
<malc_>
# String.make 1 'a';;
<malc_>
- : string = "a"
<malc_>
cool, eh?
joshcryer has joined #ocaml
<Jessehk>
hehe, yup. Thanks.
pango_ has joined #ocaml
smimou has quit ["bli"]
malc_ has quit ["leaving"]
Jessehk_ has joined #ocaml
pango has quit [Remote closed the connection]
Jessehk_ has left #ocaml []
bzzbzz has joined #ocaml
Jessehk has quit [Read error: 110 (Connection timed out)]
Jessehk has joined #ocaml
MisterC has quit [Connection timed out]
Aradorn has quit ["This computer has gone to sleep"]
lmbdwr has quit [Remote closed the connection]
Aradorn has joined #ocaml
Aradorn has quit ["This computer has gone to sleep"]
Jessehk has left #ocaml []
ikaros has quit [Read error: 110 (Connection timed out)]
ikaros has joined #ocaml
danly has quit ["Leaving"]
Aradorn has joined #ocaml
ikaros has quit [Read error: 110 (Connection timed out)]
ChoJin has joined #ocaml
Aradorn has quit ["This computer has gone to sleep"]
sponge45 has joined #ocaml
Aradorn has joined #ocaml
Aradorn has left #ocaml []
ikaros has joined #ocaml
sponge45 has quit ["zzzzzzzzzz"]
sponge45 has joined #ocaml
microcape has joined #ocaml
<seafood_>
What is the order of evaluation in OCaml?
<Smerdyakov>
You think that is a question answerable effectively over IRC?
<seafood_>
Okay, then let me rephrase. How do I force order of evaluation
<Smerdyakov>
That doesn't make sense to me.
<seafood_>
Alright. I'll go into more detail. I have a call that opens a system process using Unix.open_process_full "<something> > foo.txt"
<seafood_>
This program does output stuff.
<Smerdyakov>
I would prefer a more abstract example.
<seafood_>
I then try to "open file foo.txt" and discover that it doesn't exist. I then ran strace a found that the open system call (which is indirectly called by openfile) occurred before the system process forked.
<seafood_>
But, in my code, the system process appeared before the open file in a let expression further up the page.
<seafood_>
Obviously the order of evaluation is not what I want it to be.
<Smerdyakov>
No, I don't think that has anything to do with it.
<seafood_>
Here's a more abstract example. I have "let a = <exp> in let b in <exp>". I expected that a would be evaluated followed by b
<seafood_>
Smerdyakov: Why do you think that?
<seafood_>
strace doesn't lie.
<Smerdyakov>
open_process_full takes two arguments. You're probably ignoring a warning about partial application.
<seafood_>
Oh. I gave it two arguments.
<seafood_>
And I don't have errors in my program at all.
<seafood_>
It's very small.
<Smerdyakov>
Then maybe the issue is that open_process_full runs the command in parallel.
<Smerdyakov>
...and you aren't waiting for it to finish before proceeding.
<seafood_>
Okay, now we're getting somewhere. The fact of the matter is that I don't want it to finish.
<seafood_>
I want to continually send it stuff, have it spit out more output and then read from the file.
<Smerdyakov>
Well, you aren't even waiting for it to write anything to the file.
<Smerdyakov>
That is, waiting for it to create the file in the first place.
<seafood_>
Well, not entirely. I have an expression like this in my program "<send something to process that should make it spit out output>; openfile foo.txt [O_RDONLY; O_NONBOCK] 600"
<seafood_>
This fails for some reason.
<Smerdyakov>
In any case, 'let' expression are definitely evaluated in the order you said you expected.
<seafood_>
I thought so, so what's going on?
<Smerdyakov>
You have no guarantee that the process actually generates the output before the 'openfile' is reached.
<seafood_>
Yes. Agreed. But it should.
<seafood_>
Why should it block?
<Smerdyakov>
"Block"?
<Smerdyakov>
This is _parallel_ execution.
<Smerdyakov>
You have to plan for _arbitrary_ interleavings.
<seafood_>
I send some characters to the process that should make it output stuff. I even flush these characters.
<Smerdyakov>
OK, let's try an analogy to humans.
<seafood_>
Okay, how do I plan for this?
<seafood_>
I see you point.
<seafood_>
*your
<Smerdyakov>
I sign a contract saying that I will mail you a sack of gold if you mail me a penny.
<Smerdyakov>
You mail the penny, and then you go to open the sack of gold.
<Smerdyakov>
But I haven't sent it yet. :)
<seafood_>
Sure.
<seafood_>
Thanks
<Smerdyakov>
Why are you redirecting to a file instead of using pipes?
<seafood_>
I want this to work on Windows too.
<Smerdyakov>
I'm talking about the return value of open_process_full.
<Smerdyakov>
You already went to the trouble of calling the version that returns three stream handles, so why aren't you using them?
<seafood_>
The return value of open_process_full is a triple of channels (stdout, stdin, stderr)
shawn has quit [Connection timed out]
Smerdyakov has quit ["Leaving"]
<seafood_>
Smerdyakov: Okay, I originally took that approach but I'm just not getting all the output I should. I've used a call to input and only received 67 bytes out about 2000 that I should have.
<ChoJin>
I didn't understand the problem :)
<ChoJin>
Oh, I just got it
<ChoJin>
your subprocess is the open writting in foo.txt
<ChoJin>
why don't you wait for the subprocess to terminate before continuing?
<ChoJin>
(in low level unix stuff, usually using a waitpid() kind of thing)
<ChoJin>
seafood_: still there?
sponge45 has quit ["zzzzzzzzzz"]
Roughest has quit [Remote closed the connection]
johnnowak has joined #ocaml
shawn has joined #ocaml
ChoJin has quit ["This computer has gone to sleep"]
_velco has joined #ocaml
khaladan has joined #ocaml
<pango_>
seafood_: you should use pipes (and that works on windows, too)
slipstream-- has joined #ocaml
khaladan has quit [Connection timed out]
slipstream has quit [Read error: 110 (Connection timed out)]
ChoJin has joined #ocaml
beschmi has joined #ocaml
pango_ has quit [Remote closed the connection]
pango has joined #ocaml
johnnowak has quit []
love-pingoo has joined #ocaml
_fab has joined #ocaml
ChoJin has quit ["This computer has gone to sleep"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
llama32 has joined #ocaml
velco has joined #ocaml
Skal has joined #ocaml
johnnowak has joined #ocaml
ramkrsna has quit [Remote closed the connection]
Skal has quit [Remote closed the connection]
johnnowak has quit []
<pauld>
Can anybody explay the difference between runnning ocaml < script.ml and ocaml script.ml?
<pauld>
I've been trying to get HereDoc to work with script for 2 days. See this example: http://pastecode.com/9664
Smerdyakov has joined #ocaml
stevan_ is now known as stevan
beschmi has quit ["Leaving"]
rillig has joined #ocaml
Eridius has quit []
llama32 has quit [Remote closed the connection]
Eridius has joined #ocaml
<Eridius>
pauld: running "ocaml < script.ml" makes it think you're typing, so it's print a bunch of stuff as if it were interactive
<Eridius>
"ocaml script.ml" tells it you want to run script.ml, so you'll notice it's not echoing everything
<pango>
ocaml -I +camlp4 -I `ocamlfind query HereDoc` unix.cma camlp4o.cma pa_HereDoc.cma text.cmo hereme.ml works (with hereme.ml containing no directive)
david_koontz has joined #ocaml
_JusSx_ has joined #ocaml
ChoJin has joined #ocaml
ChoJin has quit ["This computer has gone to sleep"]
Eridius has quit []
rillig has left #ocaml []
ChoJin has joined #ocaml
ChoJin has quit [Client Quit]
danly has joined #ocaml
_velco has quit ["I'm outta here ..."]
asmanian has joined #ocaml
asmanian_ has joined #ocaml
asmanian_ has quit [Read error: 104 (Connection reset by peer)]
love-pingoo has quit [Remote closed the connection]
love-pingoo has joined #ocaml
Eridius has joined #ocaml
aavh has joined #ocaml
<aavh>
silly question: if i have two files, a.ml and b.ml, where a.ml references B.x and b.ml references A.y, how do i compile them?
<aavh>
(since the compiler wants the dependencies of each file to precede it in the argument list)
<stevan>
I would suspect (but dont know really) that they would need to be in the same file
<aavh>
oh, ok, so with that construct, i would define modules A and B in a single file.
<aavh>
("Recursion between compilation units is a different problem that is not adressed yet.")
<stevan>
aavh: looks as if it might not even be possible
<aavh>
yeah.
<stevan>
aavh: maybe you could abstract the relationship using functors
<aavh>
in my real code, i've got two files: core.ml and database.ml. core.ml calls functions in database.ml, while database.ml uses a type defined in core.ml.
<aavh>
hence, the circular dependency.
<aavh>
i guess i could define the type in a third module.
Eridius has quit []
stevan has quit ["Leaving"]
asmanian has quit ["Verlassend"]
smimou has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
shawn has joined #ocaml
mbishop has quit [Remote closed the connection]
love-pingoo has quit ["Connection reset by pear"]
pango has quit ["Leaving"]
pango has joined #ocaml
Submarine has joined #ocaml
roughest has joined #ocaml
gunark has quit [Connection reset by peer]
_fab has quit [Read error: 110 (Connection timed out)]