flux changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 4.00.1 http://bit.ly/UHeZyT | http://www.ocaml.org | Public logs at http://tunes.org/~nef/logs/ocaml/
zbroyar has quit [Quit: Leaving.]
<path[l]> one more question if you dont mind guys. I'm replacing a part of a statement (an else clause) that has return type unit, with a pattern match. How do I make the pattern match return unit
ollehar has quit [Ping timeout: 264 seconds]
turnersr has joined #ocaml
wormphlegm has quit [Ping timeout: 264 seconds]
wormphlegm has joined #ocaml
turnersr has quit [Ping timeout: 264 seconds]
turnersr has joined #ocaml
<Drup> path[l]: just make sure that every branch of the pattern match return unit, that's all :)
<path[l]> ah ok
wrp6 has joined #ocaml
chrisdotcode has joined #ocaml
chrisdotcode has quit [Ping timeout: 260 seconds]
n06rin has joined #ocaml
osa1 has joined #ocaml
demonimin_ has joined #ocaml
demonimin has quit [Ping timeout: 246 seconds]
kaka22 has joined #ocaml
<kaka22> hi guys
<kaka22> in ocaml, do we have anything to comment out a line, like // in C, or # in python?
<kaka22> i hate (* & *), because i have to go to the end of line to put *). and when i uncomment, i have to do more work, too
<kaka22> any other choice?
mfp has quit [Ping timeout: 246 seconds]
<n06rin> how to make simple output in ocaml? somethink like print in python?
<pippijn> kaka22: unfortunately not
<pippijn> n06rin: printf, maybe?
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
Neros has quit [Ping timeout: 260 seconds]
<kaka22> pippijn: oh too bad. cant we just improve ocaml on this aspect??
<pippijn> yes, we can
<pippijn> it would be trivial from a code perspective
structuralist has joined #ocaml
<pippijn> kaka22: you could make a ticket at the bug tracker or write on a mailing list
<pippijn> see what other people say
<pippijn> what would you suggest?
<pippijn> // doesn't work, because that's a valid ocaml operator
<kaka22> pippijn: whatever that is not in use in current syntax. maybe #?
<pippijn> # is also in use
<pippijn> it's the object member access operator
<pippijn> obj#member
path[l] has quit [Quit: path[l]]
<kaka22> oh i see. how about %?
<pippijn> it's also a valid operator
<pippijn> and used for function composition
<kaka22> in use i think
<kaka22> so ocaml already use everything :-). how about /* ?
<pippijn> well
<kaka22> so (* comment few lines, and /* comment 1 line only
<pippijn> let me put it this way
<pippijn> # let (/*) a b = Printf.printf "%d /* %d\n" a b;;
<pippijn> val ( /* ) : int -> int -> unit = <fun>
<pippijn> # 2 /* 3;;
<pippijn> 2 /* 3
<kaka22> so impossible? if you do that way, you can also define (* (before it was used)
<pippijn> right, but it was never not used
<pippijn> so nobody used it
<kaka22> anything can be defined in ocaml, but lets put something besides for line comment
<pippijn> you might break old code
<pippijn> -- is actually used
<pippijn> --- maybe
<kaka22> pippijn: so what is impossible to not break old code?
<pippijn> [- maybe
<pippijn> I don't think you can define anything starting with [
<pippijn> [ is the start of special list and array syntax
<pippijn> as well as string indexing with .[
<pippijn> so [- could be the single line coment
<pippijn> comment
<pippijn> it's only slightly confusing, because [ usually expects ]
<pippijn> and editors assume that with their paren-matching
<Drup> staring at my keyboard, here are symbols that can't be used in ocaml identifier or operators : § £ ø °
<kaka22> that makes sense
<pippijn> Drup: yeah :\
<pippijn> and those are not on all keyboards
<pippijn> I can't type the pound thing
<kaka22> pippijn: can you raise this issue in ocaml committee, so they will consider that? it is important i think
<pippijn> I can type €
<pippijn> kaka22: I am not on any committee
<Drup> kaka22: put in on the bug tracker
<kaka22> no guys, ignore those special chars. stick with ascii chars only
<dsheets> why not configure your editor to comment/uncomment a line?
<dsheets> what if *) happens in a single-line comment?
<Drup> I'm almost sure you iwill not be able to do it with ascii only
<dsheets> let ( * ) = ... is allowed, too
<pippijn> indeed I don't think you can change the lexical grammar in a backwards compatible way
<dsheets> should be a simple macro to goto begin of line, insert (*, goto end of line, insert *)
<dsheets> and inverse as well
<kaka22> dsheets: you are talking about a special editor that allows you to do that.
<Drup> kaka22: what editor are you using ?
<dsheets> kaka22, an editor for programming should be programmable...
<kaka22> Drup: well, i am not talking about a particular editor, but about how to support one line comment, which should not depend on editor
<kaka22> btw, i am using vim, which certainly let me do that :-)
<dsheets> <kaka22> i hate (* & *), because i have to go to the end of line to put *). and when i uncomment, i have to do more work, too
<dsheets> sounds like a lot of work
<kaka22> dsheets: because i am lazy
<dsheets> does vim have an ocaml mode? something like comment-region and uncomment-region?
wormphlegm has quit [Ping timeout: 268 seconds]
<kaka22> dsheets: should have, with some plugin at least
wormphlegm has joined #ocaml
<pippijn> yes
<pippijn> it does
<dsheets> that solution will achieve satisfaction faster than a syntax change will propagate
<pippijn> I use it
<Drup> kaka22: I just looked at the ascii spec again. afai can see, every single ascii printable character can be placed legitimately in beginning of a line in the current syntax.
<pippijn> nerd commenter
<kaka22> Drup: so we should combine 2 chars, not one, like the case of (*
<Drup> kaka22: you can probable do exotic character combination, ;* should be ok
<Drup> but it looks weird
<Drup> most easy looking combination I can think of do not work
<kaka22> how about combining 3 chars?
<kaka22> that looks very ugly, however
<Drup> yes, it does :)
<Drup> `* would work
<kaka22> is this possible: ///?
<kaka22> or ###?
<dsheets> \\?
<Drup> oh right, I forgot \
zarul has quit [Remote host closed the connection]
<Drup> is it used anywhere in ocaml syntax except string escaping ?
<Drup> kaka22: ///, no. ###, yes
zarul has joined #ocaml
<chris2> (*) perhaps?
* chris2 uses an emacs function so long
<kaka22> if (*) works that would be the best choice i think
<Drup> curently, (*) is a valid stupid comment
<kaka22> but ### is way faster to type
<chris2> yes
<chris2> why not ##?
<Drup> kaka22: you have also to be careful with widly spreaded syntax extensions
<chris2> Drup: really?
<Drup> ## is used by js_of_ocaml
<chris2> ah, ok
<Drup> I'm not sure about ###, but I might define it as "dangerous" :]
<chris2> #! would be useful :P
<Drup> but tbh
<Drup> I don't think the ocaml community can reach a consensus on this topic within the foreseeable future :)
<Drup> kaka22: you're not the first one to rant about this ;)
<chris2> @@ was added without lots discussion, was it?
<kaka22> Drup: i am sure i am not the first
<dsheets> chris2, @@?
n06rin has quit [Read error: Connection reset by peer]
<chris2> function application in 4.01
<dsheets> ooo
<Drup> (and valid operator, anyway)
<chris2> read the changelog
<chris2> Drup: yes, defined now by default
<Drup> you can still redefine it, my point is that any valid operator is out of the question
n06rin has joined #ocaml
walter has joined #ocaml
<chris2> i'm not proposing making @@ a comment :)
<chris2> just saying that new stuff can come in quickly
<Drup> I would not call this "quickly" :D
zarul[afk] has joined #ocaml
<chris2> i wish let!-do-syntax had been added :/
<pippijn> yes
zarul has quit [Disconnected by services]
<pippijn> it's so simple
<pippijn> it's a trivial AST transformation
<pippijn> what's wrong with it? why is it not in?
<chris2> no idea
<Drup> syntax confusion ?
<chris2> there was a very long thread
<Drup> ! is used for other things in the ocaml syntax
<chris2> like open! now? :P
zarul[afk] has quit [Read error: Connection reset by peer]
<Drup> method! is overwriting inherited method
<Drup> open! is overwriting scope
<pippijn> is there an open!?
<pippijn> what does it do?
zarul has joined #ocaml
q66 has quit [Quit: Leaving]
<chris2> pippijn: undocumented so far
<Drup> pippijn: afaik, it silence the warning about shadowing when opening a module
<pippijn> I never saw that warning
<pippijn> is it new?
<chris2> yes
<pippijn> I see
<Drup> yeah, 4.01
<pippijn> ok
<pippijn> I'm not sure that's useful
<pippijn> I'm sure I'll get lots of warnings :)
<Drup> oh it's insanely useful.
<Drup> I got numerous painful bug because of shadowing
<pippijn> I see
<pippijn> I don't think I have
darkf has quit [Read error: Connection reset by peer]
darkf has joined #ocaml
<pippijn> I got some 1 minute questionmarks above my head because of shadowing
<pippijn> because the compiler rejected my program
<pippijn> but I haven't had runtime bugs with that
watermind has quit [Read error: Connection reset by peer]
zarul has quit [Ping timeout: 268 seconds]
<pippijn> has anyone used bisect or another ocaml code coverage tool?
kaka22 has quit [Quit: Leaving]
<pippijn> oh well, it needs ocaml 4+
<pippijn> so I won't be using that for another half a year or so
<pippijn> I hope the next ubuntu LTS contains it
<pippijn> anyway, I'm wondering (because I will probably use it at home, just not in the CI builds), how to use bisect unintrusively
<pippijn> or in a minimally intrusive way
osa1 has quit [Ping timeout: 245 seconds]
walter has quit [Quit: This computer has gone to sleep]
dsheets has quit [Ping timeout: 240 seconds]
n06rin has quit [Read error: Connection reset by peer]
slack1256 has joined #ocaml
<slack1256> .sig files are used per project? Or how various libraries get consensus on using the same .sig and providing interfacing on that?
<slack1256> basically, how to avoid to end up with 2 different (but equally powerful) .sig files?
piotrm0 has quit [Remote host closed the connection]
osa1 has joined #ocaml
n06rin has joined #ocaml
shinnya has quit [Ping timeout: 240 seconds]
ygrek_ has joined #ocaml
<pippijn> .sig?
<pippijn> slack1256: ocaml has .mli
turnersr has quit [Quit: Leaving]
<pippijn> what's a .sig file?
<slack1256> Well, it's basically the same.
<slack1256> you understood me :-)
n06rin has quit [Read error: Connection reset by peer]
n06rin has joined #ocaml
Drup has quit [Quit: Leaving.]
dnm_ has quit [Ping timeout: 256 seconds]
<pippijn> ok, I don't understand your question anyway
n06rin has quit [Quit: Leaving.]
<slack1256> how different libraries agree on the use of the same .mli file?
n06rin has joined #ocaml
<slack1256> both of them can make their own .mli file which are basically equivalent
<pippijn> slack1256: if two libraries have the same module, they are in conflict and can't be used together
<slack1256> can't they be different interfaces of the same module?
<pippijn> .mli is compiled to .cmi
<pippijn> there can only be one .cmi per module
<slack1256> !!
<slack1256> ok
n06rin has quit [Client Quit]
<pippijn> wow
<pippijn> putting code into nested modules just cost me 6% performance
<pippijn> that's just weird
<pippijn> module M = struct (*code*) end open M
<pippijn> is 6% slower than just the code
<pippijn> this makes me sad :\
gnuvince has joined #ocaml
gnuvince has quit [Changing host]
gnuvince has joined #ocaml
<slack1256> that's a known deficiency. But the real question is "is it fast enough?"
gnuvince has left #ocaml []
<pippijn> no
<pippijn> it's not
<pippijn> but I just went down from 1.4 seconds to 0.5
<pippijn> by not allocating closures
<pippijn> and now I'm removing the last closure (I think)
<pippijn> it's beginning to look ok now
slack1256 has quit [Quit: Konversation terminated!]
<pippijn> 0.485
<pippijn> time for another round of profiling
chrisdotcode has joined #ocaml
structuralist has quit []
<pippijn> 0.45 with unsafe
<pippijn> 0.43 caching String.length
<pippijn> can ocaml link statically against libc?
turnersr has joined #ocaml
<pippijn> never mind
<pippijn> it's 0.33 seconds on Intel Xeon E3-1225 V2 @ 3.20GHz
<pippijn> and 0.45 seconds on Intel Core2 Duo T6400 @ 2.00GHz
kaka22 has joined #ocaml
<kaka22> hi guys
<kaka22> what is the equivalence of uint64_t (in C) in ocaml??
<pippijn> int64
<kaka22> pippijn: how about unsigned part?
<pippijn> oh
<pippijn> nope
<pippijn> no such thing
<kaka22> pippijn: why ocaml doesnt care about the sign?
<pippijn> short answer: because of type inference
<kaka22> pippijn: oh i see.
<kaka22> how about long int? i cannot seem to find that in ocaml
<pippijn> what do you expect of long int?
<pippijn> C says: long is at least 32 bits
<pippijn> ocaml says: int is at least 31 bits
<pippijn> so basically long is int in ocaml
<pippijn> ocaml doesn't have C's int (which is at least 16 bits)
<kaka22> pippijn: in C, on 64bit, long and int are different
<pippijn> yes, and?
<pippijn> you want two different ints in ocaml?
<kaka22> so i am used to that, and wondering if there is such a distinction in ocaml
<pippijn> no
<pippijn> int is 63 bit on 64 bit platforms
<kaka22> ok, just to make sure
<pippijn> in C, it's easy to have lots of int types
<pippijn> because of implicit conversions
<pippijn> in ocaml, there are no implicit conversions, because of type inference
ggole has joined #ocaml
ben_zen has quit [Ping timeout: 246 seconds]
osa1 has quit [Ping timeout: 260 seconds]
venk` has joined #ocaml
wagle has quit [Ping timeout: 246 seconds]
venk has quit [Remote host closed the connection]
hellome has quit [Ping timeout: 240 seconds]
Nahra has quit [Ping timeout: 240 seconds]
jave has quit [Ping timeout: 240 seconds]
Nahra has joined #ocaml
jave has joined #ocaml
<adrien> gasche: I believe that "make -f Makefile.nt world.opt" on windows does not build the doc and wanted some confirmation that it's expected
<adrien> gasche: but I should ask Jonathan
wagle has joined #ocaml
brendan has quit [Remote host closed the connection]
brendan has joined #ocaml
mort___ has joined #ocaml
<adrien> patches working on freebsd, linux; need to check windows
<kerneis> CIL compiled with ocamlbuild on an 8-core: 1min20, reduced to 58s with -j 12
<adrien> :D
<kerneis> so there is a speed-up, but Amdhal's law kills you (and ocamlbuild could probably do better as well)
<adrien> I'm finally nearing the end of the cross-compilation patches
<adrien> after my next batch, there should be only a few patches left and they should be simple
<kerneis> great
<kerneis> which means I need to integrate the cross-compile patches in ocaml-autoconf as well
<kaka22> i am writing some simple wrapping C for ocaml. it is very simple, and declared like this:
<kaka22> external total: int -> int -> int -> int = "total"
<kaka22> let x = total 3 4 8;;
<kaka22> in which, total() is a external C function
<adrien> kerneis: oh, you're working on that? \o/
<kaka22> the problem is: total (x, y, z) always get the correct value of x & y, but not z
<kaka22> any idea why??
<pippijn> what's ocaml-autoconf?
<pippijn> hmm
<kaka22> inside total(), i simply get value out by Val_int(). x & y is correct, but z is always wrong ??
<kerneis> pippijn: at set of macros for autotools
<adrien> kerneis: well, I don't know how to handle that because currently the compiler will be named "ocamlc" and not "i686-foo-bar-ocamlc"; but I guess it's a requirement for autoconf
<pippijn> interesting
<pippijn> and automake?
<kerneis> yes
Myk267 has joined #ocaml
<pippijn> does it work with pmake?
<adrien> kerneis: hmm, don't name your stubs the same as the ocaml function
<pippijn> netbsd make?
<adrien> erf
<adrien> kaka22: ^
<pippijn> or does it need gmake?
<adrien> kaka22: rename the C function to "ml_total"
<kaka22> adrien: why i have to rename it??
<adrien> good practice :)
<kerneis> pippijn: I'm not sure what pmake is, but I guess it needs gmake since autotools are a GNU thing
<pippijn> no
<adrien> but otherwise, we need to see the whole source
<adrien> kerneis: pmake is another implementation of make
<adrien> kerneis: it's "sane"
<pippijn> kerneis: automake (still) produces very portable makefiles
<pippijn> that work on all modern makes (bsd make, gnu make, sgi make, ...)
<adrien> (with its own issues but it's saner than gnu make; for instance the conditionals are clean)
<kerneis> but it doesn't say much
<adrien> and pmake gave birth to other makes you find on *bsd
<pippijn> pmake is also quite a lot faster than gmake
<pippijn> 2 or 3 times as fast
<adrien> hmmm
<adrien> how can it be? the calling the commands should dwarf anything that *make do
<pippijn> it matters on incremental builds
<pippijn> on the first build, that time is of course dwarfed by the actual commands
<pippijn> but if it has little to do
<pippijn> perhaps just updating a document
<pippijn> then it matters
<adrien> that doesn't sound like anything intrinsic (is that a gallicism?)
<adrien> which means it should probably be easy to fix in gnu make
<pippijn> maybe
<pippijn> gmake could be optimised
<adrien> less system calls?
<pippijn> no
<pippijn> better data structures
<pippijn> better code
<pippijn> and I'm not sure gmake could be optimised that much (since it's more powerful)
<pippijn> pmake is simpler
<pippijn> no %.pattern: %.rules
<adrien> doesn't it have an equivalent?
<pippijn> it has .rules.implicit:
<pippijn> those are more restricted, so they can be implemented more efficiently
<ggole> kaka22: hard to say without code to look at
<pippijn> besides
<pippijn> adrien: yes, maybe gmake can be optimised
<pippijn> but *right now* it is not
<pippijn> pmake is 2-3 times faster than gmake, now
<kaka22> ok guys, i found a bug !
<adrien> well, if it's cpu-bound and not I/O-bound, it's probably going to be more difficult
<kaka22> sorry for the noise!
<adrien> than I thought
<adrien> kaka22: what was it?
<pippijn> yes, it's fully cpu-bound
<pippijn> moving the tree to ramdisk doesn't help
<kaka22> adrien: i used Val_int() instead of Int_val()
<adrien> ah :)
<kaka22> yeah stupid
<adrien> C stubs are difficult
<ggole> Hooray, macro type checking
<kaka22> not that much, just my stupid mistakes
<pippijn> is it safe to make the ocaml type of raw C pointers (not custom blocks) private int?
<ggole> No, can't represent char *
<kaka22> ocaml is pretty fun, i can say :-)
<pippijn> ggole: hm?
<ggole> int eats one bit that you need for char *
<pippijn> does it actually eat it?
<pippijn> if the stub returns the thing without Val_int
<pippijn> does ocaml sometimes randomly eat it again?
<kaka22> a question: in C wrapper, if i want to return an empty list from a function, how should i code?
<ggole> Not sure: wouldn't want to guess
<ggole> Why not introduce a ptr type?
<ggole> kaka22, see the manual page on interfacing with C
<pippijn> assignment of int is direct
<pippijn> assignment of abstract goes through caml_modify
<pippijn> just a thought :) nothing serious
<pippijn> I'm just wondering
<ggole> Hmm
<kaka22> ggole: where to find that manual?
mort___ has quit [Quit: Leaving.]
<ggole> Also look in the topic for some useful links.
<kaka22> ok found Val_emptylist btw
<ggole> Alright, I gotta go vote o/
<ggole> brb democracy
<adrien> GAH
<adrien> config/Makefile.mingw defines a variable DO
<adrien> then
<adrien> I translate the makefile to ocaml
<adrien> that variable becomes "do"
<adrien> which is a reserved keyword
<adrien> this is makedriving me mad
<kaka22> a question: where can i get "mingw32" ocaml compiler suites?
<kaka22> so i can cross-compile from linux to target windows?
<adrien> you cannot do that yet
<adrien> support should be in trunk by the end of the month
<adrien> unless you want to do it through wine
<kaka22> adrien: end of this month?
<adrien> (there are also builds for debian but quite old, fedora but not in the newer versions, ...)
<adrien> kaka22: yeah, roughly
<kaka22> oh, wine can do that with ocaml windows? is that good?
<adrien> unless I get crazy and get sent to a hospital before
<kaka22> adrien: hopefully not :-)
<adrien> well, I've never tried but it could work; it might be fairly annoying to do however
<kaka22> need you to save the world :-)
turnersr has quit [Quit: Leaving]
<kaka22> on interfacing with C, Store_field(blk, num, val) seems to store number only. how can i store a string?
<kaka22> i want to store a string into a record
Arsenik has joined #ocaml
<kaka22> in my code, i am doing: Store_field(record, 0, char *), and ocaml complains
<kaka22> ok, i am using ocaml_copy_string(), compile is ok, but then my code crashes now ...
<adrien> ocaml_string_copy? or caml_string_copy?
<adrien> also, enable all warnings in the C compiler
<kaka22> adrien: sorry, caml_copy_string()
<adrien> your record is already created?
<kaka22> ok, one sec, i will paste my code somewhere
shinnya has joined #ocaml
<kaka22> adrien: i want to create a list of record. this simple code crashes:
<kaka22> please can you take a look? perhaps i did something wrong when creating the list
<kaka22> that is C code
mort___ has joined #ocaml
<adrien> hmmm, your code refers to rec_insn but you don't define it
<kaka22> i did define it above, which i didnt paste in that code (to keep it short)
<kaka22> oops
<kaka22> that should be rec_insn, not rec
<kaka22> so the code is still correct, just i copied it out wrongly
<kaka22> i fixed it here, but that is still the same code, with correct variable this time http://pastebin.com/PzPqYsCH
<kaka22> the old code would not compile, right. my code compiles without any problem
<adrien> am I wrong or are you creating a circular list with one element
<adrien> ?
<kaka22> i got segmentation fault actually
<kaka22> adrien: yes, this is simple list with 1 member only
<kaka22> but that is not the point. i am trying to figure out why this crashes
<adrien> you're building ocaml native code or bytecode?
<kaka22> native i guess. i created cmx
<adrien> yeah, native
<adrien> you can run the code in gdb and look at the backtrace with "bt" when it crashes
milosn has quit [Read error: Connection reset by peer]
<kaka22> adrien: i found where it crashes: right after this line:
<kaka22> Store_field(rec, 0, 100);
<kaka22> so after caml_alloc(), when i write to it with Store_field(), it crashes
<kaka22> any idea??
milosn has joined #ocaml
<kaka22> rec = caml_alloc(1, 0);
<kaka22> i understand 1 here is the number of field, correct??
<adrien> run it inside gdb, let it run, look at the backtrace
<adrien> although I'm not sure why you allocate space to put the int 100
<adrien> you should be able to directly use Val_int(100) I think
<adrien> and have you used CAMLlocal()?
<kaka22> adrien: that is for the record with 1 int member, with value 100
<kaka22> adrien: yes i did
<kaka22> CAMLlocal<N> for all local vars
<adrien> you still need to pass Val_int(100) instead of just 100
<adrien> if you don't, you're going to lack the GC bit and that can easily kill the GC
<adrien> since the GC triggers on allocations...
<kaka22> oh?
<kaka22> still segfault :-?
<kaka22> i changed that to Val_int(100), still crashed
<ggole> Paste the code?
<adrien> can you put the whole code somewhere?
_habnabit has quit [Read error: Connection reset by peer]
<kaka22> adrien: the whole code is little messy, i need to clean it a bit
chrisdotcode has quit [Ping timeout: 264 seconds]
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
milosn has quit [Read error: Connection reset by peer]
_habnabit has joined #ocaml
mort___ has quit [Ping timeout: 245 seconds]
milosn has joined #ocaml
<kaka22> adrien, ggole: here is my code: http://pastebin.com/pz9VCL1x
<kaka22> it is very simple, just few lines. and it crashes after i store to the "cons"
<kaka22> so line 10 makes it crash
<ggole> You need to make use of CAMLparamx and CAMLreturn macros, for a start.
<adrien> I'll look when I'm done with this commit message
shinnya has quit [Ping timeout: 240 seconds]
<adrien> it's worth looking at their implementation
ulfdoz has joined #ocaml
<kaka22> ggole: ok i fixed that with CAMLparamN and CAMLreturn, but that makes no difference in this case anyway
<kaka22> here is the new code, but basically it is still the same http://pastebin.com/KGy0NFsT
<kaka22> line 11 crashes it
<ggole> OK, let's have a look
<ggole> Works fine here
<ggole> (Not that it means much.)
<adrien> call Gc.compact after the C call
<adrien> Gc.compact ()
<kaka22> adrien: what you mean?
<kaka22> ggole: my code works for you?
<ggole> Reassigning list is a bit strange, but I don't think it should break the code
<ggole> Yeah
<adrien> Gc.compact () is a good way to trigger crashes due to C stubs
Simn has joined #ocaml
<adrien> pretty good test
<ggole> There should be a Gc.verify_heap for that.
<kaka22> ggole: it crashed even before that
<ggole> I guess I'd step through it in gdb
<kaka22> not sure if that matters, but i declare this C code in ocaml like this:
<kaka22> external test: unit -> int list = "test2"
<kaka22> and call it with: let x = test();;
<ggole> That looks ok.
<kaka22> but that doesnt matter i think
<ggole> How are you compiling the C code?
<kaka22> ok let me paste it here. not sure that matters anyway
<kaka22> ocamlc -c ocaml.c
<kaka22> i put that test2() in ocaml.c
<kaka22> it works perfectly until that line 11, and even printed out the debug message
<kaka22> so i dont think compiling is the problem
<ggole> Mmm.
<ggole> Duno.
<ggole> *Dunno.
mort___ has joined #ocaml
<ggole> I'd recompile the C with -g and step through it under gdb.
<ggole> With -O1 -g, actually
<kaka22> ok let me upload the whole code ....
chambart has joined #ocaml
<kaka22> ggole and adrien: where should i upload the whole code? only 3 tiny files: Makefile, wrap.c & .ml file
<adrien> pastebin the three of them at the same time but with 10 lines of blank between each?
<kaka22> ok pls wait
<kaka22> here is the link: http://pastebin.com/gS9QR2QA
<kaka22> there are 3 files, each starts with ####
<kaka22> sorry about the TAB in Makefile, you have to replace <Space> with <Tab> yourself
<kaka22> simply "make", and "test" will be produced.
<kaka22> ./test will have segfault
<ggole> You're missing a prototype for caml_alloc
<ggole> #include <caml/alloc.h>
<kaka22> oh why it never complains?
chambart has quit [Ping timeout: 264 seconds]
<ggole> It should. Does here.
<adrien> -Wall -Wextra -Wwrite-strings
<ggole> (Warning only.)
<adrien> (at least)
<kaka22> oh no more crash!
<ggole> -std=c89 too
<ggole> Right, prototypes are important
<kaka22> this is crap. i forgot to include a header, and it crashes???
<ggole> Welcome to C.
<kaka22> ggole: well, i do program C for 10 years or so, and never see any case like this
<adrien> I'm a bit surprised that it didn't complain because of prototype-mismatch
<kaka22> yes, i am shock actually
<ggole> If you have any serious experience you should understand the issue.
<ggole> You know that with a missing prototype arguments are assumed to be int, right?
<ggole> So the compiler will just grab whatever memory location or register happens to be there?
<adrien> well, quite often, even with that, it works
<adrien> but it's mostly luck
<ggole> He's lucky that it crashed.
<kaka22> ok i can say that in this case
chambart has joined #ocaml
<kaka22> thank guys, i dont think i can solve this bug myself!
<ggole> kaka22: to avoid problems in future, add a bunch of warning flags to your makefile
<kaka22> ggole: that is a good idea
<kaka22> that -Wall -Wextra -Wwrite-strings are for both ocamlc, ocamlopt, right?
<adrien> you'll have to pass them as -ccopt '-Wall -Wextra -Wwrite-strings'
<adrien> so ocamlc gives them to the underlying C compiler
<adrien> (I don't know how much these are portable to other compilers though)
<adrien> other C* compilers
<ggole> clang and icc are ok with them afaik
<kaka22> great, thanks!
<kaka22> now another code crashes on me, and this time there is no warning from compiler:
<kaka22> i tried to store a record into a list, like this:
<kaka22> oh no ...
<kaka22> turn out that ocaml cannot tell me if a particular var is not initialized before using?
<kaka22> i missed this line:
<kaka22> cons = caml_alloc(2, 0);
<kaka22> ...
<kaka22> Store_field(cons, 0, rec);
<kaka22> if i missed the "cons = ...", ocaml doesnt complain at all
<adrien> when doing the C side, you're doing C; you're far from OCaml
<adrien> it's unfortunate there aren't many helpers however
<ggole> Unfortunately GC protection of variables involves assigning neutral values (so that the GC never sees junk data). This prevents most of gcc's warnings about uninitialised values.
chambart has quit [Ping timeout: 264 seconds]
<adrien> pippijn:
<adrien> on freebsd
<adrien> ocaml/testsuite # time make clean
<adrien> 0.309u 0.309s 0:00.62 96.7% 309+1744k 0+0io 0pf+0w
<adrien> on linux with gnu make:
<adrien> <lots of leaving/entering subdirectories>
<adrien> make clean 2.94s user 0.40s system 53% cpu 6.203 total
<adrien> not the same machine but that's a 20x difference; however the two don't do the same work quite clearly
<kaka22> i still dont get the difference between list and array. any enlighten?
<ggole> list = singly linked list. array = uh, array.
<kaka22> ggole: when list is better than array?
<kaka22> and in Ocaml both of them can be extended at runtime, right?
<ggole> When you want to write nice clean functional code, usually
<ggole> Arrays are of fixed size (the size need not be a constant).
chambart has joined #ocaml
<ggole> Lists are also persistent, which is nice.
shinnya has joined #ocaml
ulfdoz has quit [Read error: Operation timed out]
demonimin_ is now known as demonimin
<kaka22> i am trying to print out all the records in a list, with this simple code:
<kaka22> let () = List.iter (func r -> Printf.printf "0x%x\t%s\n" r.age r.name) list_of_record
<kaka22> but ocaml complains: ')' expected. what is wrong here?
<ggole> fun, not func
<ggole> (Wow, that's a poor error message.)
<kaka22> oops, thanks
Yoric has joined #ocaml
<jpdeplaix> gildor: is there a specific order for internal build depends in oasis ? I have packages that are given in a wrong order (the dependency is given after the base)
milosn has quit [Read error: Connection reset by peer]
milosn has joined #ocaml
<jpdeplaix> gasche: did you see the fabrice's mail on the caml-list ? It seems to be a good optimization (if it's not already done)
mfp has joined #ocaml
mort___ has quit [Quit: Leaving.]
darkf has quit [Quit: Leaving]
q66 has joined #ocaml
Drup has joined #ocaml
ygrek_ has quit [Ping timeout: 268 seconds]
<jpdeplaix> gildor: oh that's (I guess) because tags_of_pathname returns a Set
<jpdeplaix> :(
<kaka22> guys, i wrote some Ocaml library. now i want to package it, so other can use it by just "open mylib". any guide on how to package the Ocaml module?
<kaka22> i want a guide starting from bunch of .ml file, to make Ocaml module for others to use
<mrvn> kaka22: I recommend using oasis
<rks`> I don't.
<kaka22> rks`: what is wrong with oasis?
<kaka22> i mean i want to package the lib, even in binary form, so people can get it, install, then use it
<mrvn> on debian? redhat? windows?
<kaka22> mrvn: on debian first. but i will need to do that for windows later
<kaka22> mrvn: perhaps even simple .zip file should be ok, so all linux distro can use it
<adrien> you can't really package ocaml libs in binary form
<adrien> because it will only work on one ocaml compiler version and configuration
<kaka22> adrien: like i give the users some .cmx, cmxa, or whatever file. is that not OK?
<mrvn> kaka22: and that is supposed to work on my s390x system?
<adrien> it can work, as long as they use the same compiler (version) as you do
<kaka22> mrvn: i am thinking about x86 only
<kaka22> adrien: oh ocaml is that bad on backward compatibility?
<mrvn> kaka22: so it won't work on any computer sold in the last 10 years since they are amd64.
<adrien> it's not bad at it
<adrien> it uses checksums to guarantee ABI compatibility
<mrvn> kaka22: ocaml has 0 backward or forward compatibility on binaries.
<kaka22> mrvn: x86 include amd64, no?
<mrvn> kaka22: no, x86 is 32bit, amd64 it 64bit.
<kaka22> mrvn: then i would say i need 2 editions: 32-bit and 64-bit
zpe has joined #ocaml
<adrien> multiply that by the number of compiler versions you want to support
<mrvn> kaka22: at least. and then there are more and more arm users.
<mrvn> Does a windows amd64 ocaml lib work on linux?
<adrien> hmm?
<adrien> no
<adrien> bytecode that doesn't use C stubs is portable
<mrvn> so multiply by windows, mac, linux
<mrvn> kaka22: what license do you want to use?
<kaka22> mrvn: i prefer BSD, but that also depends on company. they might not want that, i dont know
ulfdoz has joined #ocaml
Yoric has quit [Ping timeout: 248 seconds]
zpe has quit [Remote host closed the connection]
<adrien> pippijn: it's frustrating that you have to chose between a clean make with a proper syntax and high-level constructs (pmake and its derivates)
<adrien> pippijn: and a make with all the features you need
Drup has quit [Ping timeout: 240 seconds]
zpe has joined #ocaml
Yoric has joined #ocaml
zpe has quit [Ping timeout: 260 seconds]
Yoric has quit [Ping timeout: 248 seconds]
ben_zen has joined #ocaml
<jpdeplaix> gildor: fixed. Sorry
kaka22 has quit [Quit: Leaving]
ollehar has joined #ocaml
ollehar has quit [Read error: Connection reset by peer]
ollehar has joined #ocaml
beginner42 has joined #ocaml
beginner42 has quit [Read error: Connection reset by peer]
zpe has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
talzeus has joined #ocaml
<adrien> hmpf
<adrien> the warning-list in the manpage is everything but up-to-date
ohama has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
tobiasBora has joined #ocaml
watermind has joined #ocaml
<watermind> opam update gives me an error: .opam/opam/extprot.1.1.1.opam", line 12, character 25-26: parse error.
<watermind> that line is: ["omake" "test"] {ounit:installed}
ollehar has quit [Ping timeout: 268 seconds]
<watermind> full file here: http://pastebin.com/nu8DBpLX
<watermind> any advice?
zpe has joined #ocaml
zpe has quit [Ping timeout: 264 seconds]
talzeus has quit [Remote host closed the connection]
tobiasBora has quit [Quit: Konversation terminated!]
talzeus has joined #ocaml
tobiasBora has joined #ocaml
tobiasBora has quit [Ping timeout: 264 seconds]
walter has joined #ocaml
gnuvince has joined #ocaml
gnuvince has quit [Changing host]
gnuvince has joined #ocaml
talzeus has quit [Remote host closed the connection]
dsheets has joined #ocaml
lusory has joined #ocaml
mfp has quit [Read error: Connection reset by peer]
cdidd has quit [Ping timeout: 264 seconds]
osa1 has joined #ocaml
cdidd has joined #ocaml
mfp has joined #ocaml
Drup has joined #ocaml
Drup has quit [Ping timeout: 260 seconds]
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
oriba has joined #ocaml
<orbitz> If i have a library that is just one module, should I make an archive out of it or just give the .cmo etc
<adrien> archive
<adrien> and .cmxs
<orbitz> thanks
chambart has quit [Ping timeout: 264 seconds]
chambart has joined #ocaml
n06rin has joined #ocaml
tane has joined #ocaml
yacks has quit [Ping timeout: 246 seconds]
ygrek_ has joined #ocaml
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 248 seconds]
zpe has joined #ocaml
zpe has quit [Ping timeout: 260 seconds]
chambart has quit [Ping timeout: 264 seconds]
ygrek_ has quit [Ping timeout: 264 seconds]
chambart has joined #ocaml
chambart has quit [Ping timeout: 264 seconds]
Neros has joined #ocaml
tov has quit [Quit: leaving]
tov has joined #ocaml
ulfdoz has quit [Read error: Operation timed out]
walter has quit [Read error: Connection reset by peer]
walter has joined #ocaml
walter has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 248 seconds]
chrisdotcode has joined #ocaml
zarul has joined #ocaml
walter has joined #ocaml
yacks has joined #ocaml
Yoric has joined #ocaml
yacks has quit [Read error: Connection reset by peer]
yacks has joined #ocaml
walter has quit [Read error: Connection reset by peer]
walter has joined #ocaml
zarul has quit [Ping timeout: 268 seconds]
oriba has quit [Quit: oriba]
zarul has joined #ocaml
mathieui has quit [Quit: upgrade]
Yoric has quit [Ping timeout: 248 seconds]
ggole has quit []
xavierm02 has joined #ocaml
ulfdoz has joined #ocaml
Yoric has joined #ocaml
CissWit has joined #ocaml
walter has quit [Quit: This computer has gone to sleep]
darkf has joined #ocaml
tani has joined #ocaml
tane is now known as Guest46844
Guest46844 has quit [Killed (brooks.freenode.net (Nickname regained by services))]
tani is now known as tane
gnuvince has quit [Remote host closed the connection]
ohama has joined #ocaml
Arsenik has quit [Remote host closed the connection]
chrisdotcode has quit [Ping timeout: 260 seconds]
yacks has quit [Read error: Operation timed out]
testcocoon has quit [Quit: Coyote finally caught me]
Yoric has quit [Ping timeout: 248 seconds]
osa1 has quit [Ping timeout: 245 seconds]
testcocoon has joined #ocaml
n06rin has quit [Quit: Leaving.]
walter has joined #ocaml
walter has quit [Quit: This computer has gone to sleep]
mathieui has joined #ocaml
walter has joined #ocaml
walter has quit [Client Quit]
Yoric has joined #ocaml
dch has joined #ocaml
Yoric has quit [Ping timeout: 248 seconds]
dch has quit [Quit: how now brown cow?]
ulfdoz has quit [Ping timeout: 264 seconds]
osa1 has joined #ocaml
osa1 has quit [Client Quit]
BiDOrD_ has quit [Ping timeout: 248 seconds]
BiDOrD has joined #ocaml
BiDOrD has quit [Ping timeout: 260 seconds]
xavierm02 has quit [Ping timeout: 245 seconds]
mathieui has quit [Quit: saturday saturday fun fun fun]
mathieui has joined #ocaml
xavierm02 has joined #ocaml
Yoric has joined #ocaml
Yoric has quit [Ping timeout: 248 seconds]
<pippijn> adrien: yes, the difference is smaller with non-recursive make (the only kind of setup I have in my own projects)
<pippijn> adrien: with recursive make, it's worse, yes
<pippijn> adrien: at some point, I started generating input to automake, because automake doesn't have support for pattern rules
<pippijn> adrien: and I still wanted to support pmake
<pippijn> adrien: once upon a time, I was a heavy gmake hacker, but it becomes unmaintainable if you want to support automake input with pure gmake (which is what I did)
chrisdotcode has joined #ocaml
xavierm02 has quit [Remote host closed the connection]
chrisdotcode__ has joined #ocaml
chrisdotcode__ has quit [Remote host closed the connection]
ollehar has joined #ocaml
chrisdotcode has quit [Ping timeout: 264 seconds]
chrisdotcode__ has joined #ocaml
ollehar1 has joined #ocaml
ollehar has quit [Ping timeout: 264 seconds]
transfinite has quit [Ping timeout: 245 seconds]
transfinite has joined #ocaml
tane has quit [Quit: Verlassend]
chrisdotcode__ has quit [Ping timeout: 260 seconds]
Simn has quit [Quit: Leaving]
transfinite has quit [Ping timeout: 264 seconds]
chrisdotcode has joined #ocaml
ollehar1 has quit [Ping timeout: 260 seconds]
transfinite has joined #ocaml