vect changed the topic of #ocaml to: OCaml 3.07 ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn, ICFP'03 http://www.icfpcontest.org/, A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/, A free book: http://cristal.inria.fr/~remy/cours/appsem, Mailing List (best ml ever for any computer language): http://caml.inria.fr/bin/wilma/caml-list
eternite_0 has quit ["Arlg connection crash!"]
gim_ has quit ["dodo...."]
_JusSx_ has quit ["[BX] Time to make the donuts"]
Kinners has left #ocaml []
Iorek has joined #ocaml
Iorek has quit [Read error: 104 (Connection reset by peer)]
Iorek has joined #ocaml
async has quit [Read error: 60 (Operation timed out)]
cjohnson has quit ["Got to be good lookin' 'cause he's so hard to see."]
Herrchen has quit [Read error: 110 (Connection timed out)]
Iorek has quit [Read error: 110 (Connection timed out)]
Maddas has quit [sterling.freenode.net irc.freenode.net]
mellum has quit [sterling.freenode.net irc.freenode.net]
mellum has joined #ocaml
Maddas has joined #ocaml
<shrimpx> Smerdyakov: you around?
ott has joined #ocaml
<ott> re all
Herrchen has joined #ocaml
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
mattam_ is now known as mattam
_JusSx_ has joined #ocaml
<_JusSx_> wuuru : hi
<wuuru> _JusSx_: :-)
ott has quit [Read error: 110 (Connection timed out)]
ott has joined #ocaml
ott has quit ["BitchX-1.0c16 -- just do it."]
buggs|afk has quit ["maybe it crashed"]
ott has joined #ocaml
ott has quit [Read error: 60 (Operation timed out)]
ott has joined #ocaml
karryall has joined #ocaml
ott has quit [Read error: 60 (Operation timed out)]
gim_ has joined #ocaml
ott has joined #ocaml
<ott> re all
<karryall> hi
The-Fixer has quit ["Goodbye"]
ott has quit ["BitchX-1.0c16 -- just do it."]
mimosa has joined #ocaml
Shrdlu has joined #ocaml
wazze has joined #ocaml
Etaoin has quit [Read error: 60 (Operation timed out)]
mimosa has quit [sterling.freenode.net irc.freenode.net]
Herrchen has quit [sterling.freenode.net irc.freenode.net]
voltron has quit [sterling.freenode.net irc.freenode.net]
lam has quit [sterling.freenode.net irc.freenode.net]
Smerdyakov has quit [sterling.freenode.net irc.freenode.net]
vect has quit [sterling.freenode.net irc.freenode.net]
voltron has joined #ocaml
lam has joined #ocaml
mimosa has joined #ocaml
Smerdyakov has joined #ocaml
Herrchen has joined #ocaml
Herrchen has quit [Connection timed out]
Chimp has joined #ocaml
Chimp has quit [Client Quit]
Iorek has joined #ocaml
owll has joined #ocaml
owll has quit [Read error: 104 (Connection reset by peer)]
_JusSx__ has joined #ocaml
Herrchen has joined #ocaml
_JusSx_ has quit [Read error: 60 (Operation timed out)]
smkl has quit ["brb"]
Defcon7 has quit ["changing servers"]
smkl has joined #ocaml
Defcon7 has joined #ocaml
vect has joined #ocaml
cprokt has joined #ocaml
_JusSx__ has quit ["BitchX: EPIC on steroids."]
__DL__ has joined #ocaml
_JusSx_ has joined #ocaml
det has quit ["ircII EPIC4-1.1.2 -- Are we there yet?"]
<Iorek> I have two modules, A and B... A uses functions from B and B uses functions from A. I am not getting these two to compile, they keep complaining about "Reference to undefined global ..."
<Iorek> I mean, the compiler keeps complaining
<__DL__> you can't have easiliy mutaual recursive module.
<Iorek> so it seems...
<Iorek> I'm reading the ocaml manual and I think I will have to reorganize my modules
<Iorek> I had thought using interfaces would solve this problem
<__DL__> you should look to the end of the manual022.html (the one about ocamlc)
<Iorek> __DL__: thanks, I'm looking at it right now :)
<__DL__> by the way, I know that there was something about recursive module in the cvs version of ocaml.
<__DL__> I don't remind if this is always only on some cvs version, or if it is in the ocaml 3.07 version
<Iorek> I have 3.07
<gim_> in a same file in 3.07 you can have recursive modules
<Iorek> hm...
<Iorek> I would prefer to keep them in separate files
<gim_> i don't think it is possible ...
<Iorek> ok, so I guess I will have to find another way to organize them
<gim_> that's what i do when i have such problems...
<Iorek> well, thanks
<smkl> you can probably use stub functions
<gim_> i don't know why the modules associated to file are not/can't be defined as mutualy recursive...
<Iorek> hm... what if I use a functor ?
karryall has quit ["home"]
cjohnson has joined #ocaml
shawn has joined #ocaml
__DL__ has quit [Remote closed the connection]
__DL__ has joined #ocaml
Shrdlu is now known as Etaoin
Iorek has quit ["Je suis devenu un peu dingue"]
cprokt has quit [Remote closed the connection]
Etaoin has quit [Read error: 110 (Connection timed out)]
Defcon7 is now known as Teflon
Demitar has joined #ocaml
maihem has joined #ocaml
yella has joined #ocaml
<yella> hi
<Smerdyakov> Hiiii
maihem has quit ["Client exiting"]
<yella> imagine there is data transmitted over the networked and stored in a string. the data contained different C integers (u_int8,u_int16)
<yella> is it possible to unmarshal it correctly to a ocaml type or something ?
<Smerdyakov> Is that really what you mean to ask? Cleary you can unmarshall it manually.
<Smerdyakov> Clearly
<yella> hm
<yella> how?
<yella> manually?
<Smerdyakov> You don't see how, given the list of bytes in the string?
<yella> well since I don't have something like type casting i thought im unmarshalling it into a type
<Smerdyakov> What does that mean?
<Smerdyakov> Given a list of bytes and knowledge of the integer encoding scheme used, it's trivial to determine what the integers were.
<yella> well i dont't know how
<yella> i thought something like this is working..but i guess im wrong
<yella> type t = { aa: int; bb: int}
<yella> let s =Marshal.to_string [1;2] []
<yella> ..
<Smerdyakov> For instance, here's how you unmarshall a string containing a single 8-bit integer:
<yella> (Marshal.from_string s 0 : t);;
<Smerdyakov> int_of_char (String.get s 0)
<Smerdyakov> Now let's say we have a 16-bit number:
<Smerdyakov> int_of_char (String.get s 0) + 256 * int_of_char (String.get s 1)
<Smerdyakov> Assuming little endian
<Smerdyakov> Get it?
<yella> yes
<yella> but this is extremely uncomfortable if you have a large datastructure
<Smerdyakov> Nonetheless, an arbitrary network format used by a C program is not necessarily going to match up with that used by the marshalling libraries that come with OCaml.
<yella> look i don't know the language well..i want to achieve something like a type cast (i know it does not exist) e.g. "ip = (struct ip*) string_data"
<Smerdyakov> I don't think it will be possible.
<Smerdyakov> I would hope it's not possible.
<Smerdyakov> It's not a very type safe sort of thing to do!
<Hadaka> yella: problem with what you are asking is that complex ocaml data structures are not linear
<yella> i hoped it were possible in some way
<Hadaka> yella: they are composed of pointers and more pointers
<Hadaka> yella: so no single string can hold anything more than a simple record or an array
<Hadaka> not to mention all the other problems :)
<Hadaka> by using marshaling to read and write the values, you achieve kind of a similar value - but the format is in no way stable, and is prone to change between even minor changes in ocaml versions
<Hadaka> similar effect, not similar value
__DL__ has left #ocaml []
The-Fixer has joined #ocaml
<yella> but this is a bit problematic. How do you fill data in a record then?
<Hadaka> Smerdyakov: actually, typecasting is trivially possible - Obj.magic is the function and it types as 'a -> 'b
<Smerdyakov> Read each "atomic" value and fill it yourself.
<Hadaka> Smerdyakov: and youa re quite right, it's not type safe at all ;)
<Smerdyakov> Hadaka, and it doesn't _work_ for what he wants to do. :P
<Hadaka> exactly
<Hadaka> yella: I missed the beginning of the discussion I'm afraid, what is it that you exactly wished to do?
<Smerdyakov> <yella> imagine there is data transmitted over the networked and stored in a string. the data contained different C integers (u_int8,u_int16)
<Smerdyakov> <yella> is it possible to unmarshal it correctly to a ocaml type or something ?
<yella> in other words
<yella> i have a ocaml string containing a c struct and i want to "type cast" it into a ocaml record (or is it called type?)
<wuuru> :-) :-)
<Hadaka> yella: an ocaml record has a completely different memory layout from a similar c struct - the string will never be of the correct format
<Hadaka> yella: you have to create a new record from the data you have extracted from the string
asiammyself has joined #ocaml
asiammyself has left #ocaml []
<yella> i just want to prevent two extract every byte manually like Smerdyakov showed above
<Smerdyakov> You can't.
<yella> err too
<yella> to
<yella> :)
<Smerdyakov> Use modular design to avoid duplicated effort.
<Hadaka> yella: mldonkey source code has rather nice functions for that
<Hadaka> let get_int8 s pos = ...
<Hadaka> etc.
<Smerdyakov> The pos business is nasty.
<Smerdyakov> You want some kind of stream/parser abstraction.
<Hadaka> for parsing a few integers from a simple string... not really
<Hadaka> besides, you might not be reading them in order even
Demitar has quit ["Bubbles..."]
<yella> i thought on a stream approach aswell
<Hadaka> { a = get_int16 str 0; b = get_int16 str 2; c = get_int16 str 4; ... }
<yella> I also converted the ocaml string into a ocaml int32 array and a bunch of Int32.logand functions
<yella> but it was a mess
<Hadaka> ocaml int32 array is an array of pointers to custom objects that are the actual int32's
<yella> yes I converted it to real int32 types using camlidl functions
<Hadaka> so that's actually a two-level datastructure
<Hadaka> camlidl should have some nice printf style conversion functions iirc
<yella> I will try your { a = get_int16 str 0 .. } idea.
<yella> for a small structure it seems feasible
<Hadaka> well, that was just an example that it doesn't need to look *that* ugly - even though manual unmarshalling / marshalling is always ugly
<Hadaka> I have actually plans to build a kind of a network packet parsing library, that would handle this trivially - but that's in the queue after quite a few other projects
<yella> sounds nice
<yella> however..thanks for now. I'm gonna try and i will probably come back heh
<yella> later
yella has left #ocaml []
<Maddas> heh, a Swiss.
<Smerdyakov> Haha, damn those funky Swiss.
* Maddas eyes Smerdyakov
<Maddas> Did I already mention that I'm Swiss, too? :)
<Hadaka> something similar to mldonkey's AnyEndian/LittleEndian/BigEndian should be in a common library though... everybody ends up coding their own versions of them anyway
Etaoin has joined #ocaml
Riastrad1 has joined #ocaml
Riastradh has quit [Nick collision from services.]
Riastrad1 is now known as Riastradh
tomasso has joined #ocaml
wazze has quit ["If we don't believe in freedom of expression for people we despise, we don't believe in it at all -- Noam Chomsky"]
emu has quit [Read error: 60 (Operation timed out)]
The-Fixer has quit ["Goodbye"]
Demitar has joined #ocaml
Teflon is now known as Defcon7
mimosa has quit ["I like core dumps"]
_JusSx_ has quit ["BitchX: the NEW form of birth control!"]
gim_ has quit ["zZzz"]
det has joined #ocaml
buggs has joined #ocaml
Demitar has quit [Read error: 110 (Connection timed out)]
buggs has quit ["maybe it crashed"]