lus|wazze has quit [Read error: 110 (Connection timed out)]
Kinners has left #ocaml []
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
TimFreeman has joined #ocaml
<TimFreeman>
Can someone with ocaml 3.07 run a short test program for me? I have 3.06 installed and I think I found a bug.
<TimFreeman>
The program is only five lines:
<TimFreeman>
let len: int = 32000;;
<TimFreeman>
let buf: string = String.create len;;
<TimFreeman>
let infd: Unix.file_descr = Unix.openfile "/dev/zero" [Unix.O_RDONLY] 0;;
<TimFreeman>
let bytes: int = Unix.read infd buf 0 len;;
<TimFreeman>
let _ = Format.eprintf "bytes is %d, len is %d.\n@?" bytes len;;
<TimFreeman>
In ocaml 3.06 on Linux, it reads 16384 bytes, not the requested 32000.
<TimFreeman>
Hmm, looks like everyone is away from the keyboard. Sleep well, I may bug you in the morning.
<TimFreeman>
Here's how you compile the program: ocamlc unix.cma foo.ml -o foo
occam has joined #ocaml
<smkl>
TimFreeman: what about if you try to read 100 bytes or so?
occam has left #ocaml []
<TimFreeman>
smkl: That works fine. The limit is 16384.
<Smerdyakov>
TimFreeman, you have not read the read() documentation carefully enough.
<Smerdyakov>
TimFreeman, the function is working correctly.
<TimFreeman>
Smerdyakov: Cite some documentation. I read it quite carefully in the last hour and I disagree.
<smkl>
it doesn't guarantee that it reads all the bytes requested
<TimFreeman>
Smerdyakov: Unix.read is documented to work like the Unix read system call. The Unix read system call reads 32000 bytes when I ask it to read 32000 bytes from /dev/zero.
<Smerdyakov>
TimFreeman, that's a lucky break for you.
<TimFreeman>
smkl: The unix read system call does read the number of bytes requested if you are reading from a file.
<TimFreeman>
smkl: This has been the traditional behavior of the unix read system call for as long as it has existed.
<Smerdyakov>
TimFreeman, but the function has never been specified in documentation so as to require that behavior.
<Smerdyakov>
TimFreeman, try man 2 read to see for yourself.
<TimFreeman>
Smerdyakov: It isn't luck. Unix read works that way.
<Smerdyakov>
No, the abstract specification of Unix read has never worked that way.
<TimFreeman>
There's no reason for ocaml to emit a call to read 16384 bytes when I ask it to read 32000.
<Smerdyakov>
So?
<Smerdyakov>
Why does there need to be a "reason"?
<Smerdyakov>
It fits the specification.
<smkl>
ocaml implementation uses an internal buffer for some reason ... that's why it's truncated
<TimFreeman>
smkl: What's the reason? I gave it a buffer, all it has to do is call the Unix system read function and pass it my buffer and the size I requested.
<smkl>
hmm, because of the offset parameter
<smkl>
which is pretty useless, but ...
<smkl>
see otherlibs/unix/read.c ... i have to go
<smkl>
i guess you could just do buffer+offset when reading
<TimFreeman>
smkl: I'm reading the POSIX standards. I'm sure it's in there somewhere. I agree that it isn't in the Linux "man 2 read" page.
<TimFreeman>
smkl: But I'll continue tomorrow. Bedtime.
__DL__ has joined #ocaml
bk_ has joined #ocaml
mimosa has joined #ocaml
bk_ has quit ["I'll be back"]
__DL__ has quit [Read error: 104 (Connection reset by peer)]
karryall has joined #ocaml
systems has joined #ocaml
g1m has joined #ocaml
bk_ has joined #ocaml
buggs|afk has joined #ocaml
buggs has quit [Connection timed out]
systems has left #ocaml []
buggs|afk is now known as buggs
<krosfells>
j'ai defini un type : type type_validite = | Validite of (string*type_etats) list;;
<krosfells>
et une fonction
<krosfells>
let rec appartient e l = match l with
<krosfells>
[] -> false
<krosfells>
| t::q -> (e = t) || appartient e q ;;
<krosfells>
Mais quand j'essai d'utiliser appartient
<krosfells>
let v = Validite [("p",Etats [2]);("q",Etats [3])]in
<krosfells>
appartient ("p",Etats [2]) v;;
<krosfells>
j'ai une erreur This expression has type type_validite but is here used with type (string * type_etats) list
<krosfells>
Comment je peut faire pour resoudre ce probleme en gardant appartient polymorphe ?
<mellum>
krosfells: it seems to me the problem is that v is no list
<mellum>
krosfells: maybe you should define the type as type type_validite = (string*type_etats) list
<krosfells>
Ok thanks. It's work preety well
<karryall>
krosfells: or change the pattern matching in appartient Validite [] -> ... | Validite (t::q) ->
<krosfells>
karryal: i prefer the other solution because with Validite [] the function becomes non generic. But thanks too
<karryall>
btw, there's List.mem that exactly this already
bk_ has quit ["I'll be back"]
bk_ has joined #ocaml
vegai has joined #ocaml
lus|wazze has joined #ocaml
systems has joined #ocaml
<systems>
whats new
systems has quit ["Client Exiting"]
<vegai>
not much, it seems
nittch has joined #ocaml
<nittch>
hi everybody
<nittch>
i have some works to do for my school in Caml
<nittch>
but i must use LaTeX for it
<nittch>
anyone have an idea to have a syntax recognition in LaTeX for Caml ?
<karryall>
you mean some kind of LaTeX pretty-printing of OCaml programs ?
<nittch>
french speaking ?
<karryall>
yep
<karryall>
enfin oui
<nittch>
:)
<nittch>
ben en fait
<nittch>
je début en LaTeX et en Caml
<nittch>
et j'ai un boulot scolaire a faire en LaTeX
<nittch>
des Exos sur Caml
<nittch>
j'aimerais avoir un moyen
<nittch>
d'avoir style la syntaxe reconnue pour Caml
<nittch>
j'entends par la style les mots clé en gras, paramètres en couleurs.....
<nittch>
pour mon code Caml
<nittch>
une idee ?
<mimosa>
le manuel caml
<mimosa>
caml.inria.fr
<nittch>
bah ca concerne pas plutot LaTeX ?
<karryall>
y'a des outils de literate programming qui font ça
<karryall>
regarde ocamlweb
<mimosa>
ah tu veux un pretty-print de code caml ?
<nittch>
pretty-print ?
<krosfells>
nittch je te conseil le mode tuareg sous emacs et puis apres tu convertie ton source en ps avec les couleurs et tout.
<nittch>
bah la je met ca dans du \begin{verbatim}
<nittch>
tuareg j'utilise vi
<karryall>
ocamldoc (dans la distrib ocaml) peut aussi generer du LaTeX
<krosfells>
ben si c'est juste pour imprimer le code sources en joli y'a un truc sous emacs pour convertir ton buffer un poscript
<karryall>
krosfells: oui mais ça fait du .ps, pas du LaTeX
<nittch>
je pourrais pas avoir un environnement latex
<karryall>
ah non ocamldoc ca va pas, il ne garde pas le code dans la sortie LaTeX
<nittch>
style \begin{ocaml}let.... \end{ocaml}
<nittch>
?
<karryall>
nittch: regarde ocamlweb
<nittch>
oki
<karryall>
a+
karryall has quit ["uikend"]
<nittch>
ocamlweb a l'air de correspondre a ce que j'attends
bk_ has quit ["I'll be back"]
d2003xx has joined #ocaml
nittch is now known as nittch_[miam]
d2003xx has left #ocaml []
nittch_[miam] is now known as nittch
systems has joined #ocaml
TimFreeman has left #ocaml []
systems has quit ["Client Exiting"]
nittch has quit [Remote closed the connection]
karryall has joined #ocaml
mattam_ has joined #ocaml
systems has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
phm_ has joined #ocaml
<phm_>
hi
systems has quit ["Client Exiting"]
phm_ has quit ["bye"]
lus|wazze has quit ["These pretzels are making me thirsty!"]
Yinntee has joined #ocaml
mattam_ is now known as mattam
Yinntee has quit ["Leaving"]
yinntee has joined #ocaml
yinntee is now known as yinnte
yinnte has quit ["#gnu"]
yinnte has joined #ocaml
DavidW2 has left #ocaml []
mw_ is now known as mw
yinnte has quit ["[BX] The best part of waking up is BitchX in your cup"]