mbishop changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.0 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
<fax> can anyone explain why http://rafb.net/p/DyrSVc82.txt
<fax> why I get a bus error?
<fax> I think external div : int -> int -> int * int = "div";; is wrong
<fax> because it is calling that function div which causes the bus error
<Smerdyakov> Find a tool that generates stubs automatically from C header files.
<fax> :(
<fax> I don't understand why the compiler writers never implement structs as values
<fax> Can you think of any programming langauge worth using which has a C interface which can do structs as values?
<krumms> fax: you'll need to be more specific than that if you want a helpful answer
bluestorm_ has quit ["Konversation terminated!"]
<Smerdyakov> SML's NLFFI does struct pointers.
<Smerdyakov> You really need passing of structs by value?
<fax> yes
<fax> I want to deal with a language (implemented in C) for its libraries, and they use structs as values very often
<fax> I just spent the last week adding this feature to a different compiler to come up with more problems as always... hoping to find some alternatives
<Mr_Awesome> type disp = int option * disp list option;;
<xavierbot> Characters 24-42:
<xavierbot> type disp = int option * disp list option;;
<xavierbot> ^^^^^^^^^^^^^^^^^^
<xavierbot> The type abbreviation disp is cyclic
<Mr_Awesome> i dont understand why this doesnt work
<Mr_Awesome> shouldnt the fact that the part with disp is an option break the cycle?
<fax> your type is like (int, (int, (int, (int, ...)))) ?
<fax> or (int, [(int, [(int, [..., ...]), ...]), ...]) ?
<fax> I dont understand what int option * disp list option is
<Mr_Awesome> something like that
<Mr_Awesome> dont worry about, its just a testcase
<Smerdyakov> Mr_Awesome, you need the -rectypes option to get such a definition accepted.
<fax> Smerdyakov: I tried to use NLFFI before but I didn't get it to work...
<Smerdyakov> fax, OK. It's very easy to use.
<fax> does it do only struct pointers and not structs themselves
<Smerdyakov> MLton only does struct pointers. Not sure about SML/NJ.
<fax> It says
<fax> "With this interface one can call C functions that are passed (and return) integers, floats, doubles, arrays, structs and unions, and functions."
<fax> I will try again with SML/NJ
<Smerdyakov> Not sure if I need to say this, but #sml is the right place for further discussion about that.
<fax> ok cheers
minciue has quit [Read error: 110 (Connection timed out)]
hsuh has joined #ocaml
seafoodX has joined #ocaml
hsuh has quit [Remote closed the connection]
fax has quit [Read error: 104 (Connection reset by peer)]
yminsky has joined #ocaml
piggybox_ has joined #ocaml
bzzbzz has quit ["leaving"]
piggybox has quit [Read error: 110 (Connection timed out)]
shawn has joined #ocaml
noteventime has quit [Remote closed the connection]
yminsky has quit []
souk_ has joined #ocaml
seafoodX has quit []
seafoodX has joined #ocaml
piggybox_ is now known as piggybox
buluca has quit [Read error: 113 (No route to host)]
msingh has joined #ocaml
<msingh> Cin, you traytor!
msingh has left #ocaml []
<Cin> :(
Smerdyakov has quit ["Leaving"]
m3ga has joined #ocaml
slipstream has joined #ocaml
fy__ has quit [Read error: 110 (Connection timed out)]
EliasAmaral has quit [Remote closed the connection]
slipstream-- has quit [Read error: 110 (Connection timed out)]
shawn has quit ["This computer has gone to sleep"]
minciue has joined #ocaml
<krumms> What's the significance of List.fold_right not being tail-recursive? The possibility of stack exhaustion?
m3ga has quit ["disappearing into the sunset"]
<pango> yes
<pango> let seq a b = let rec aux a b acc = if a > b then acc else aux a (b-1) (b::acc) in aux a b [] ;;
<xavierbot> val seq : int -> int -> int list = <fun>
<pango> List.fold_right (fun e acc -> acc + e) (seq 1 100000) 0 ;;
<xavierbot> Out of memory during evaluation.
<pango> mmh xavierbot has little memory available. Here I get "Stack overflow during evaluation (looping recursion?)."
<krumms> pango: sure, thanks
<krumms> so what's the alternative? List.rev (List.fold_left ...) ?
<krumms> I guess it depends on whether or not order is important ...
<pango> that should work fine, yes, both fold_left and rev are tailrec
<pango> maybe even List.rev (List.fold_left ... (List.rev l)) then ;)
<pango> same for map, you can use List.rev (List.rev_map ...) to handle large lists
love-pingoo has joined #ocaml
<krumms> hmm, okay - thanks!
<pango> (large depending on the size of stack; but usually in the tens of thousand elements)
bluestorm_ has joined #ocaml
krumms has quit ["Leaving"]
shawn has joined #ocaml
Mr_Awesome has quit ["time to impregnate a moth"]
seafoodX has quit []
souk_ has quit [Client Quit]
smimou has joined #ocaml
xavierbot has quit [Remote closed the connection]
xavierbot has joined #ocaml
krumms_ is now known as krumms
buluca has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
seafoodX has joined #ocaml
<bluestorm_> hm
<flux> fax
<flux> darn
<flux> I was just checking if he was here but accidentally hit enter. anyway, camlidl, as I've recently found, seems to be an excellent tool for interfacing with C libraries
<flux> I haven't tried swig out yet, though
<flux> foo;;
<xavierbot> Characters 0-3:
<xavierbot> foo;;
<xavierbot> ^^^
<xavierbot> Unbound value foo
<flux> nice, it didn't need a restart after that memory exhaustion
<flux> let foo = "bar";;
<xavierbot> val foo : string = "bar"
smimou has quit [Connection timed out]
<G> rwmjones: oh, xavierbot is yours
<rwmjones> yes
seafoodX has quit [Read error: 104 (Connection reset by peer)]
ppsmimou has quit ["Leaving"]
love-pingoo has quit ["++"]
ppsmimou has joined #ocaml
ygrek has joined #ocaml
ramkrsna_ is now known as ramkrsna
seafoodX has joined #ocaml
m3ga has joined #ocaml
shawn has quit [Remote closed the connection]
m3ga has quit [Client Quit]
minciue has quit [Read error: 104 (Connection reset by peer)]
buluca has quit [Read error: 113 (No route to host)]
minciue has joined #ocaml
lde has quit [Read error: 110 (Connection timed out)]
piggybox has quit [Read error: 110 (Connection timed out)]
leo037 has joined #ocaml
seafoodX has quit []
pantsd has joined #ocaml
xavierbot has quit [Remote closed the connection]
xavierbot has joined #ocaml
lde has joined #ocaml
minciue has quit [Read error: 110 (Connection timed out)]
piggybox has joined #ocaml
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
Tychom has quit []
Tychom has joined #ocaml
shawn has joined #ocaml
brothers has quit [Nick collision from services.]
brother1 has joined #ocaml
ijoshua has joined #ocaml
minciue has joined #ocaml
ijoshua has quit ["Quitting!"]
joshuacook has joined #ocaml
seafoodX has joined #ocaml
piggybox_ has joined #ocaml
pantsd has quit [Read error: 104 (Connection reset by peer)]
pantsd has joined #ocaml
seafoodX has quit []
piggybox has quit [Connection timed out]
krumms has quit [Read error: 110 (Connection timed out)]
piggybox_ is now known as piggybox
lde has quit [Read error: 110 (Connection timed out)]
pango has quit [Remote closed the connection]
pango has joined #ocaml
buluca has joined #ocaml
souk_ has joined #ocaml
pantsd has quit [Read error: 110 (Connection timed out)]
minciue has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
minciue has joined #ocaml
shawn has quit ["This computer has gone to sleep"]
minciue has quit [Read error: 110 (Connection timed out)]
lde has joined #ocaml
lde has quit [Remote closed the connection]
lde has joined #ocaml
souk_ has quit [Client Quit]
minciue has joined #ocaml
minciue has quit [Client Quit]
shawn has joined #ocaml
leo037 has quit [Connection timed out]
robyonrails has joined #ocaml
Submarine has joined #ocaml
noteventime has joined #ocaml
pantsd has joined #ocaml
Smerdyakov has joined #ocaml
souk_ has joined #ocaml
david_koontz has joined #ocaml
buluca has quit [Read error: 113 (No route to host)]
slipstream-- has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
<Ober> so if I convert my packet parsers from C to ocaml I should be free of many of the concerns of buffer overflows, smashed stacks, string format vulnerabilities?
<rwmjones> Ober, what packet parsers are these?
<Smerdyakov> Ober, as long as you don't call C functions from your OCaml code. :-)
<Ober> tons of code I wrote in ethereal
<Ober> yeah complete rewrite
<rwmjones> very very interesting you should talk about that
<rwmjones> I was playing with an extension I wrote called pa_bitfields
<Smerdyakov> There's a safe subset of OCaml, but the language with its standard library definitely isn't safe.
<Ober> grep -i fournier epan/dissectors/packet*c
<Smerdyakov> The FFI and Obj.magic come to mind as ways to import the old crap.
<Ober> rwmjones?
<rwmjones> which kind of has the same problem space
<Ober> dont I know you off of karl net?
<rwmjones> I don't think so?
<rwmjones> pa_bitfields itself is crap, but I'd like to work on something better
<rwmjones> s/is crap/needs lots of thought and work to be useful/
smimou has quit ["bli"]
Obre has joined #ocaml
<Ober> looking now
shawn has quit ["This computer has gone to sleep"]
<Ober> ok I see what you mean
<Ober> pack/unpack/unmarshall
<Ober> had played with tcpdump -Xx -s 1500 and lex/yacc and never got far.
<rwmjones> Ober, yes, I wanted something which would make it easy to describe & unpack & pack structures with bitfields, strange alignments, endianness, etc.
<rwmjones> my usage is for Xen hypervisor calls
<Ober> make sense
<rwmjones> but the same sort of thing applies to network protocols too
<Ober> same sort of problem
<Ober> yeap
<rwmjones> anywhere where you have a strict ABI with bitfields
<Ober> and unions that change the format of the rest of the structures. *cough*asn.1*cough*
<Ober> will take a look at it some more.
<Ober> still new to ocaml
* rwmjones switches to laptop .. back in 5 mins
shawn has joined #ocaml
rwmjones_ has joined #ocaml
Obre has quit ["leaving"]
smimou has joined #ocaml
<flux> hm, I don't think lex can be useful with parsing packets, as it's extremely context dependant, but why not yacc?
<flux> (well lex being useful as in conjunction with yacc)
<flux> or some more advanced parser generator such as menhir.. or the GLR one, the name of which escapes my mind..
<flux> rwmjones, are xen interface calls defined as c structs?
<flux> rwmjones, if so, wouldn't swig or camlidl help
<flux> rwmjones, how large are the memory structures being exchanged with xen? I'm thinking about the hassle of disabling compaction and re-enabling that (how is that going to work with threads? another thread might enable it?), wouldn't it be simpler just copy it to some malloc(1)ed memory, which wouldn't be moved by the gc..
<flux> I suppose not quite as pretty, though, and obviously there can be a performance hit - but how performance critical is the commication with xen hypervisor anyway..
ygrek has quit ["Leaving"]
<flux> the camlidl-approach to constructing data structures would be appealing because it would avoid the difficulty of padding, because it uses the C compiler for compiling the wrappers
<flux> but I can see the pa_bitfields extension still being very useful especially for network protocols, where the protocol specification doesn't depend on the platform or the compiler
<flux> especially if you could define the endianess of the words, custom packing/unpacking functions, etc..
zarvok has joined #ocaml
brothers has joined #ocaml
<rwmjones_> flux, yes they are C structs, but with strange gcc align extensions etc. Requires a proper parser.
<rwmjones_> they vary in size from the small to 10s of kilobytes
<flux> rwmjones_, yeah, but camlidl basically generates wrapper functions in C, so the C compiler takes care of all that
<flux> snipped from code generated by camlidl for ocamlesd: void camlidl_ml2c_esd_struct_esd_server_info(value _v1, struct esd_server_info * _c2, camlidl_ctx _ctx) .. (*_c2).version = Int_val(_v3); .. (*_c2).rate = Int_val(_v5); ..
<rwmjones_> performance is not so critical, it's more about tractability of the code. Obviously for ethereal performance would be of greater importance.
<flux> esd_server_info is defined in /usr/include/esd.h, while the fields I want to copy over to ocaml is listed in manually generated esd.idl
<flux> (to or from ocaml)
piggybox has quit [Read error: 110 (Connection timed out)]
brothers has left #ocaml []
brothers has joined #ocaml
Mr_Awesome has joined #ocaml
robyonrails has quit ["me ne vo'"]
brothers has quit [Remote closed the connection]
buluca has joined #ocaml
pattern has quit [Read error: 104 (Connection reset by peer)]
pantsd has quit [Connection timed out]
pantsd has joined #ocaml
joshuacook has quit ["Quitting!"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
pattern has joined #ocaml
piggybox has joined #ocaml
pattern has quit [Read error: 110 (Connection timed out)]
rumpl has joined #ocaml
<rumpl> Hi, I'm new to ocaml and co., I am truying to do some exercices for ocamllex, now it asks to replace a string, "test" for example, but not "tester", so I did a stupid " test ", but it's ugly, how could I make it change "test" but not "tester" more nicely? http://rafb.net/p/tLsSEO88.html
<rumpl> The " test " thing is no good, since it can be a \n after the word, and it won't be changed.
<rumpl> Anyone? Would you like the question in french?
jlouis has quit [Remote closed the connection]
jlouis has joined #ocaml
<mattam> You probably need to use the negation/complement construct
<rumpl> Yes, probably, will see that tomorow, thanks
rumpl has quit ["Ex-Chat"]
pantsd has quit [Read error: 110 (Connection timed out)]
pantsd has joined #ocaml
buluca is now known as _8u1Uk4z_
_8u1Uk4z_ is now known as buluca
Submarine has quit [Read error: 110 (Connection timed out)]
Demitar has quit [Read error: 110 (Connection timed out)]
Demitar has joined #ocaml
smimram has joined #ocaml
smimou has quit [Read error: 110 (Connection timed out)]
pattern has joined #ocaml
romanoffi has joined #ocaml
<romanoffi> .0