flux__ changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
shawn has quit ["This computer has gone to sleep"]
<dvorak> hrm, do functions have to have an arg list?
<mikeX> what?
<dvorak> well, if I do something like 'let hello_world = printf "Hello World\n";; then it's evaluated without being called
<dylan> functions do not have an arg list.
<dylan> All functions take one argument and return one value. :)
<dylan> you can, however, define that function like:
<dylan> let hello_world () = printf "I want my mommy!!!" ;;
<dvorak> ok
<dvorak> that wasn't clear to me from the tutorial I read, thanks
<mikeX> there is one exception I think, object methods
<dylan> mikeX: ssh, and that isn't an exception.
<mikeX> :)
<dvorak> ok, so it requires at least a unit parameter
<dylan> Yep.
<mikeX> indeed, you don't need to care about that yet dvorak (or ever, if you keep clear from OO programming in ocaml)
<dvorak> well, planning to stay clear of it now, just tying to get something simple done
<dvorak> what would be the best way to do something like perl's pack and unpack in ocaml?
<mikeX> what does that do?
<dylan> Unpacks or packs binary data strings.
<dvorak> what dylan said
<dvorak> I need to parse some dns packets
<dylan> to encode, say, an IP address into a string of 4 bytes.
<dylan> dvorak: for the love of monkeys, why? Isn't there a library for that?
<dvorak> for ocaml? maybe so, I don't know
<dvorak> it's kind of a niche need, so I assumed not
<dylan> is it something in POSIX?
<dvorak> nope
<dylan> is there a C library that does it?
<dvorak> there are a few, none really do it especially well
<dylan> Ah
<dvorak> I don't mind reinventing the wheel here though, since I'm just trying ot write some code to get familar with the language
* dylan nods
<dylan> I wrote a CGI library to do the same.
<dylan> but parsing binary packets. hmm
<dvorak> dns packets aren't real complicated overall, so a c library ends up being pretty low level, and not real useful
<dylan> you'll have a few problems.
<mikeX> it seems a bit specialized and not too fitting to ocaml
<dvorak> definitely a bit specialized
<dvorak> but I've been doing some development at work on a in house dns server, so it's something I've got fresh in my mind
<dvorak> and I can do kind of apples to apples comparisons
<dvorak> hrm, apparently someone did an ssh implementation
<dvorak> which is not too different really
hikozaemon has joined #ocaml
mikeX has quit ["zz"]
bzzbzz has joined #ocaml
bzzbzz has quit ["leaving"]
khaladan has joined #ocaml
jcreigh has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
Revision17 has joined #ocaml
jcreigh has quit ["Do androids dream of electric sheep?"]
Smerdyakov has quit ["Leaving"]
WhatTheDeuce has left #ocaml []
shawn has joined #ocaml
shawn has quit [Client Quit]
shawn has joined #ocaml
ski has quit [Read error: 104 (Connection reset by peer)]
slipstream-- has joined #ocaml
ski_ has joined #ocaml
ski_ is now known as ski
slipstream has quit [Read error: 110 (Connection timed out)]
pango is now known as pangoafk
pangoafk is now known as pango
Skal has joined #ocaml
Revision17 has quit [Read error: 110 (Connection timed out)]
hikozaemon has quit ["Leaving..."]
_metaperl has joined #ocaml
mikeX has joined #ocaml
metaperl has quit [Read error: 110 (Connection timed out)]
<_metaperl> what is structural and physical equality? how do they differ?
<flux__> physical equality -> same object
<flux__> structural equality -> same content
<_metaperl> I see
<_metaperl> thanks
<flux__> actually
<flux__> I think those are orthogonal concepts
<flux__> what is the context?
<flux__> or actually(2), maybe they are related, but don't deal with values at all
<flux__> but for example, these are structurally equivalent: type a = { a : int; b : int } and b = { c : int; d: int};
<flux__> ok, it refers to what I said earlier
<flux__> but actually I'm not convinced the book uses the proper term :-o
<flux__> maybe someone can point me to the right direction..
<mellum> well, not really orthogonal, since physical equality implies structural equality
<flux__> I was thinking structural equality being related only to types, but apparently not so then
<pango> probably some confusion between equality and equivalency (for "type compatibility" or some other relation)
<flux__> well, there's a pair of words I haven't considered being much different
<pango> in my mind equality is a case of equivalency
<flux__> ok, well, so there's no miscommunication there
yangsx has joined #ocaml
<_metaperl> I'm not following the 4-tuple here: http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora019.html ... I know that the second element is the last key pressed... but what about the rest?
<_metaperl> I'm starting to get it actually. I think each tuple position corresponds to the type listed just above it
<ketty> are you refering to the type called state?
<dvorak> so I asked this question last night, but maybe someone around now will have an answer. is there some library or preferred technique for working with binary structures in ocaml? in perl I'd use pack and unpack, but there doesn't appear to be anything similar in the standard library. I'm trying to parse DNS packets
<dvorak> I can obviously take things byte by byte out of the string, but that's fairly tedious
<ketty> exactly what does pack and unpack do? is it posible to implement them in ocaml?
<dvorak> you provide a pattern to parse the binary structure with, for example, 'C4A60' would mean 4 single byte characters, then a 60 byte ascii string
<dvorak> it'd return a 5 element list
<dvorak> or, something like 'NNnC4' would be 2 network longs, a network short, and 4 individual bytes
<dvorak> so giving that to unpack along with a string with the data would give you a 7 element list
<ketty> what about writing separate functions for every data type?
<ketty> and put them in a module...
<ketty> would it be hard?
<dvorak> yeah, I could do that, I was just hoping someone else had ;)
<dvorak> perhaps I should look at the c binding stuff, it might have code for packing and unpacking c structures
<dvorak> which is really just about what I need
<ketty> yes, i think it has that..
<dvorak> hrm, according to the docs there, the Stream module does part of what I want, but most of that functionality has been moved into camlp4
<pango> maybe extlib IO module ?
<dvorak> I didn't see anything obvious there
<dvorak> let me look again
<pango> binary files, bits,...
<dvorak> ah hah
<dvorak> yes, that's what I need ;)
<dvorak> thanks ;)
<dvorak> hrm, so those all take an input channel?
<dvorak> can I turn a string into an input channel?
<pango> val input_string : string -> input
<pango> somewhere above
<dvorak> thanks ;)
<dvorak> this looks workable
<pango> mldonkey uses Proto*.ml modules to convert back and forth between raw packets (in string buffers) to protocol messages (as variant type)
<dvorak> stuff they developed themselves?
<pango> and use simple functions like let value, new_pos = get_sometype buf pos to extract fields
<pango> (from memory)
<dvorak> ie, is the Proto stuff a library I can find somewhere, or something I'd have to pull out of the mldonkey source?
<pango> there's one module per network support (in fact often more, for example one for peer-to-peer, and one for peer-to-servers, etc.)
<dvorak> yeah, I see what you mean
<dvorak> they have some underlying library for doing that I imagine
<pango> most of them are trivial
<dvorak> looks like what I'm looking for
<dvorak> well, on something like get_int32_8, it looks like it returns an int32, but it's only creating it from a single byte
<pango> must have been some experiments, that code is commented out (thanks to syntax coloring ;) )
<dvorak> well, so what I don't see in there is get_int32
<dvorak> ah, so it's in littleEndian.ml
<dvorak> which makes sense, you need endian specific versions
yangsx has quit [Read error: 110 (Connection timed out)]
vin100 has joined #ocaml
vin100 has quit [Remote closed the connection]
khaladan has quit [Read error: 104 (Connection reset by peer)]
vincenz has quit [Client Quit]
Revision17 has joined #ocaml
Smerdyakov has joined #ocaml
work_metaperl has quit ["KVIrc 3.2.0 'Realia'"]
Revision17 has quit [Connection timed out]
finelemon has joined #ocaml
smimou has joined #ocaml
finelemo1 has quit [Read error: 110 (Connection timed out)]
shawn has quit [Connection timed out]
finelemo1 has joined #ocaml
pango is now known as pangoafk
finelemon has quit [Read error: 110 (Connection timed out)]
pangoafk is now known as pango
Snark has joined #ocaml
Lob-Sogular has quit ["Changing server"]
jbramley has joined #ocaml
shawn has joined #ocaml
shawn_ has joined #ocaml
shawn has quit [Connection timed out]
sidewinder has joined #ocaml
mikeX has quit ["later"]
Snark has quit ["Leaving"]
shawn_ has quit ["This computer has gone to sleep"]
shawn_ has joined #ocaml
dylan_ has joined #ocaml
dylan_ has quit [Client Quit]
dylan_ has joined #ocaml
dylan has quit ["Reconnecting"]
dylan_ is now known as dylan
Revision17 has joined #ocaml
rillig has joined #ocaml
shawn_ has quit ["This computer has gone to sleep"]
WhatTheDeuce has joined #ocaml
pango has quit [Read error: 145 (Connection timed out)]
_metaperl has quit ["KVIrc 3.2.1 Anomalies http://www.kvirc.net/"]
pango has joined #ocaml
smimou has quit ["bli"]
WhatTheDeuce has left #ocaml []
mikeX has joined #ocaml