hangman4 has quit [Read error: 60 (Operation timed out)]
hangman4 has joined #ocaml
mrsolo has joined #ocaml
Smerdyakov has quit ["sleep"]
humasect has joined #ocaml
ulfdoz has joined #ocaml
mrsolo has quit [Read error: 60 (Operation timed out)]
ulfdoz_ has quit [Read error: 110 (Connection timed out)]
noj has quit [clarke.freenode.net irc.freenode.net]
Nutssh has joined #ocaml
mrsolo has joined #ocaml
mrsolo has quit [Read error: 110 (Connection timed out)]
noj has joined #ocaml
Sonarman has quit ["leaving"]
booyaa has joined #ocaml
booyaa has left #ocaml []
humasect has quit [Read error: 54 (Connection reset by peer)]
_fab has quit [Remote closed the connection]
Herrchen has joined #ocaml
bronaugh has joined #ocaml
<bronaugh>
hm
<bronaugh>
is there any way to "automate" population of a type?
<bronaugh>
ie I want to create a list of tuples specifying addresses in some arbitrary in-memory data structure and names of parts of a type.
<bronaugh>
then I want to process that list, given an instance of the type, and set the particular part of the type equal to the value at the specified address in the in-memory data structure.
<bronaugh>
essentially, I want to automate population of the elements of a type.
<araujo>
anyone knows a good tutorial about creating daemon applications?
<Nutssh>
bronaugh: Huh?
<bronaugh>
Nutssh: see type. see lazy programmer.
<bronaugh>
see lazy programmer only want to type out name of field in type, and address of data to fill element of type with.
<Nutssh>
araujo: Any network programming book should help, also you might want to check the glibc docs which has a reasonable tutorial.
<bronaugh>
that explanation help any?
<Nutssh>
bronaugh: We're all lazy. Restating that is useless. What do you want.
<bronaugh>
ok, you're not lagged.
__DL__ has joined #ocaml
<bronaugh>
Nutssh: I have a type I want to populate using arbitrary, nasty, binary data in memory.
<bronaugh>
I don't want to type in all the crap needed to populate each field, over and over again. I'd rather process a list or whatever, and write that code once.
<Nutssh>
So you want a binary deserialization method.
<bronaugh>
sure.
<bronaugh>
that'd be one way to do it.
<bronaugh>
so how do you implement such a beast without a lot of repetative typing?
<Nutssh>
Ocaml doesn't have that. Best bet might be to just do it manually... But if you use a good style, it wouldn't be bad. Or if you have a huge number of binary structures, write a perl program to write the code.
<mflux_>
bronaugh, you could propably do what you want with the preprocessing facilities, that is, camlp4
<bronaugh>
camlp4 is?
<mflux_>
Camlp4 is a Pre-Processor-Pretty-Printer for OCaml. It offers syntactic tools (parsers, extensible grammars), the ability to extend the concrete syntax of OCaml (quotations, syntax extensions), and to redefine it from scratch.
<Nutssh>
mflux_, have you used camlp4?
<mflux_>
no
<Nutssh>
... I tried once, it was... hard to figure out where to start.
<mflux_>
I guess using examples (code from the caml humps) could be a useful starting point (after reading the documentation)
<araujo>
Ok Nutssh , thanks
<Nutssh>
I'd just do it manually... *with* some careful work with combinators to automate the offset-management and parsing -- automate everything but the actual stuffing into a record.
Nutssh has quit ["Client exiting"]
<araujo>
Unix.stdin is equal to the STDINFILENO in C ?
<araujo>
STDIN_FILENO even
<mflux_>
yes
<mflux_>
infact you can rudely check that with (Obj.magic Unix.stdin :> int)
<mflux_>
or you could look at the source ;)
<mflux_>
(btw, I think that's the only way to retrieve the number of a descriptor in ocaml, it could be nice to have an official mechanism for that too)
<araujo>
Thanks mflux_
Demitar has quit [Read error: 110 (Connection timed out)]
_qvisitor has joined #ocaml
qvisitor_ has quit [Read error: 113 (No route to host)]
Shammah has quit [Read error: 104 (Connection reset by peer)]
mlh_ has quit [Client Quit]
Shammah has joined #ocaml
* araujo
sees ignore() is a precious hack
<araujo>
Any danger?
pango_ has quit [Remote closed the connection]
<mflux_>
no, I use ignore too
<mflux_>
another way to write ignore is let _ = foo in ()
<mflux_>
but ignore is ok ;)
Shammah has quit [Read error: 104 (Connection reset by peer)]
Shammah has joined #ocaml
<araujo>
mflux_, :-)
<araujo>
I ask because, this sort of things usually leads to a whole of unexpected results
<araujo>
in other languages...
* araujo
falls in love with O'Caml
dodecahedron has joined #ocaml
Submarine has joined #ocaml
Shammah has quit ["Leaving"]
_shawn has joined #ocaml
shawn_ has quit [Connection timed out]
<araujo>
If i have something like: try expr1; expr2; expr3 .. with .... , the try/with will catch any exception produced by all those expressions? (of course, considering that i match with _ ->)
<Submarine>
yes
dodecahedron has quit [Client Quit]
mrvn_ has joined #ocaml
mlh_ has joined #ocaml
mrvn has quit [Read error: 110 (Connection timed out)]
Submarine has quit ["Leaving"]
vezenchio has joined #ocaml
araujo has quit ["Programs must be written for people to read, and only incidentally for machines to execute"]
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
jussx has joined #ocaml
jussx has quit ["leaving"]
gehel has joined #ocaml
jussx has joined #ocaml
mlh_ has quit [Client Quit]
_fab has joined #ocaml
Tachyon76 has joined #ocaml
Tachyon76 has quit [Read error: 54 (Connection reset by peer)]
_qvisitor has quit [Read error: 60 (Operation timed out)]
_qvisitor has joined #ocaml
smimou has joined #ocaml
_fab has quit [Remote closed the connection]
Tachyon76 has joined #ocaml
Submarine has joined #ocaml
gim has quit ["brb"]
Tachyon76 has quit ["Leaving"]
gim has joined #ocaml
araujo has joined #ocaml
gehel has quit ["leaving"]
TeXitoi has quit [Read error: 104 (Connection reset by peer)]
TeXitoi has joined #ocaml
vodka-goo has joined #ocaml
mrsolo has joined #ocaml
CLxyz has quit [Client Quit]
Snark has joined #ocaml
<Snark>
slt
<Snark>
how do I access a type foo = Int of int | String of string | Boolean of bool | etc from C?
mrsolo has quit [Read error: 104 (Connection reset by peer)]
<mflux_>
I think the ffi documentation covers that too. I think it's basically boxed, has one value in range 0-2 indicating type and another value for the data?
araujo has quit [Read error: 110 (Connection timed out)]
Gueben has joined #ocaml
Submarine has quit ["Leaving"]
TeXitoi has quit [Read error: 104 (Connection reset by peer)]
Boojum has joined #ocaml
TeXitoi has joined #ocaml
<Boojum>
re
<Boojum>
uh?
Snark has quit [Nick collision from services.]
Boojum is now known as Snark
<Snark>
better
<Snark>
hope nobody answered my question, or the answer is lost
<bronaugh>
<mflux_> I think the ffi documentation covers that too. I think it's basically
<bronaugh>
boxed, has one value in range 0-2 indicating type and another value for the
<bronaugh>
data?
Purice has joined #ocaml
pango has joined #ocaml
Herrchen has quit ["bye"]
<Snark>
bronaugh: thanks
<Snark>
what is ffi?
<mflux_>
foreign function interface. although I guess ocaml doesn't use that term.
<Snark>
hmmmm...
<Snark>
where could I find a live example of such?
Smerdyakov has joined #ocaml
Purice has quit [Remote closed the connection]
Purice has joined #ocaml
lus|wats has joined #ocaml
<mflux_>
maybe with ocaml standard libraries?
* Snark
fetches the sources
bk_ has joined #ocaml
vezenchio has quit [Read error: 110 (Connection timed out)]
* Snark
thinks he will just add an ocaml layer to take care of that
<Snark>
that will have the bonus that I won't run into typing issues if the C code is thiner
* Snark
ponders
<Snark>
yes
<Snark>
sounds good
<Snark>
arg
<Snark>
it's not possible to _read_ those
<Snark>
:-/
<smimou>
Snark: it might be a good start to have a look at Std.dump of the extlib library