<smimou>
Enveigler: in a couple you've got 2 projections for each of the 2 components
<smimou>
with an array of size n you've got n projections
<Snark>
tab.(2) is a projection
<Enveigler>
That's the same as tab[2] in c?
<smimou>
yes
<Enveigler>
The 3rd element of the array?
<smimou>
yes
<Enveigler>
Okay. Just different terminology.
Gueben has joined #ocaml
<Enveigler>
Thankyou both.
<Enveigler>
BTW is "a couple" the same as "a pair"?
Gueben has quit [Remote closed the connection]
Gueben has joined #ocaml
Gueben has quit [Remote closed the connection]
Gueben has joined #ocaml
TaXules has joined #ocaml
<Tue16499>
i have to define 'f' with let f = ... before i can use it?
<Snark>
Tue16499: of course
Gueben has quit [Remote closed the connection]
<Tue16499>
thats too bad
Enveigler has quit [Read error: 110 (Connection timed out)]
<petter_>
Tue16499: you can use an anonymous function, if thats what you mean
<Tue16499>
nah, my problem is that i have this huge ml file with classes etc in it. And i wanted to use some class method somewhere lexicographically above all this stuff
<Tue16499>
but the class etc cant be moved upwards because it again depends on shit
<Tue16499>
and making all the stuff a simultaneous assignment...
<Tue16499>
well that would just be tedious
Smerdyakov has joined #ocaml
Tue16499 has quit ["Leaving"]
Smerdyakov has quit ["work"]
Saulzar has joined #ocaml
monochrom has joined #ocaml
Saulzar has quit [Remote closed the connection]
Gueben has joined #ocaml
mrsolo has joined #ocaml
Hipo has quit [Read error: 104 (Connection reset by peer)]
Hipo has joined #ocaml
ulfdoz has quit [Read error: 110 (Connection timed out)]
Schmurtz has joined #ocaml
noj_ is now known as noj
Snark has quit ["Leaving"]
mrsolo has quit [Remote closed the connection]
mrsolo has joined #ocaml
angagon has joined #ocaml
angagon has left #ocaml []
petter_ has quit [Read error: 110 (Connection timed out)]
Godeke has joined #ocaml
Enveigler has joined #ocaml
<Enveigler>
I just read that Ocaml doesn't allow opening a file for both reading and writing. Is this an implementation thing or a philosophical thing?
<mfurr>
Enveigler: There is no way to do it with the pervasives module, but you can open a file r/w with Unix.openfile
<Enveigler>
... if your on Unix which I'm not. That aside, I just wondered what the reasoning behind the decision was?
vezenchio has quit ["\o/ in mochintin namocniuh \o/"]
<mfurr>
the vast majority of the Unix.* functions work on any platform, Unix.openfile certainly does
<mfurr>
as for the decision, I guess they wanted a type-safe input/output channels, but I can't speak for the inria people
<Enveigler>
Okay, thanks. I'll go find the Unix library
<mfurr>
its part of the standard distribution
Godeke has quit [Client Quit]
<Schmurtz>
Unix.openfile does work on any plateform
<Schmurtz>
but it's not very easy to use it
<Schmurtz>
(Unix.read and Unix.write more than Unix.openfile)
<Enveigler>
Can I use in_channel_of_descr & out_channel_of_descr on the same file descriptor simultaneously?
<Enveigler>
(And would it buy me anything by way of ease of use?)
lfelipe has joined #ocaml
<lfelipe>
hi
<lfelipe>
anyone here knows the "Modern Compiler Implementation in ML" book ?
<Schmurtz>
Enveigler, try...
<Schmurtz>
lfelipe, not me
<Schmurtz>
Enveigler, however you may experience some strange behaviour if you dont flush your after writing and before reading
<Schmurtz>
with only one fd, you have only one position cursor
<lfelipe>
I was wondering if it was going to be easy to use Ocaml with it
<Schmurtz>
if you write some data, it'll be writen at the current position in the file and this position will be updated to the end of wrtiten data
<Schmurtz>
when you read something, you'll get the data just after the previously writen text
<Schmurtz>
the best solution is to read all data, close the file
<Schmurtz>
and when you want to save the data, reopen the file with write access and rewrite the complete file
<Schmurtz>
if you use the file as a database storage (or something like that which require random read/write access), use the Unix module
<Enveigler>
Schmurtz: Thanks. I realise I'd need to seek between reads and writes. I am trying now, but falling over syntax at the moment. (I real new to Ocaml incase it wasn;t obvious :)
<Schmurtz>
and be careful to not read and write at the same time ;)
<Enveigler>
That's sounds like there is a trap (laziness?) awaiting me?
<Schmurtz>
and if you use in/out_channel, don't forget to flush (otherwise, your data will stay in a cache buffer)
<Schmurtz>
Enveigler, if you use 2 threads, one reading and one writting
<Schmurtz>
imagine you seek to the writing position, the reading thread seek to another position, and then the writing thread write in a bad position
<Enveigler>
Okay. It'll be a while before I'll be trying to thread anything :)
<Schmurtz>
:)
<Schmurtz>
in a nutshell, use only one thread for disk access
<Schmurtz>
and flush after writing data
<Schmurtz>
it should work
lfelipe has quit ["[BX] Reserve your copy of BitchX-1.1-final for the Nintendo Gameboy today!"]
<Enveigler>
Sounds good. Interesting though about flushing. If I do a write (no flush) then seek to another part of the file, the dirty buffer gets flushed to disk before anything is read at the new position?
<Enveigler>
sthough/thought/
<Schmurtz>
you never know when the data will be flushed
<Enveigler>
Okay. a writeAt pos data that flushes sounds good. Thanks.
<Schmurtz>
if you write something, it may be written immediately, or delaied
<Schmurtz>
as the ocaml lib want
<Schmurtz>
however, if you use Unix.write, I don't think you need to flush
<Schmurtz>
(but Unix.write, has other complexe behaviour)
<Enveigler>
The retry till done stuff?
<Schmurtz>
yes
<Schmurtz>
when the unix call is interrupted
<Enveigler>
I'll sort out my syntax errors and see how I get on. Thanks for your help.
<Schmurtz>
good luck
<Enveigler>
One question. Do I need to specify the location of the Unix Lib when building? (If so How?)
<Schmurtz>
you just have to add unix.cma on the ocamlc command line
<Enveigler>
C:\OCaml\test>ocamlc rdwr.ml unix.cma
<Enveigler>
Error while linking rdwr.cmo: Reference to undefined global `Unix'
<Schmurtz>
wrong order
<Schmurtz>
unix.cma must be before rdwr.ml, because rdwr.ml depends on it
<Enveigler>
Got it.
<Schmurtz>
ocaml is sometime not so nice...
mlh has joined #ocaml
Enveigler has quit [Read error: 110 (Connection timed out)]