gl changed the topic of #ocaml to: OCaml 3.07 ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn , 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 | http://icfpcontest.org/ !!
Smerdy is now known as Smerdyakov
urz has joined #ocaml
<urz> i get a segfault associated with garbage collection.. i'm passing a channel to ocaml and teh ocaml code is not useing it..
<urz> it happens in an oldify_local_nodes function
<urz> or something like that
<urz> would the ocaml code try to close the file? and if it did, could that really lead to a segfault?
<urz> not ocaml code, i mean garbage collection code
<mattam> nope, files used to be closed during finalization, but i believe not anymore
<urz> well any idea on what oldify means and what kind of error could make it segfault?
<mattam> this should not lead to a segfault anyway
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
GreyLensman has quit ["Leaving"]
<mattam> if you're passing some malformed data to ocaml
<mattam> oldify probably means classify for the second pass of garbage collection
<urz> hm
<urz> is that definately it? malformed data?
<urz> heh
<mattam> i'm no expert at this :)
<urz> should i use dup on the file descripter before i turn it into a channel and pass it back?
<urz> the c routine actually wants to call a callback with a FILE* and i'm using fileno to turn it into a file descripter and then a function in the caml source to convert it into a channel and then returning it
<urz> c = alloc_channel(open_descriptor_in(fd));
<mattam> maybe there's some error you're missing ? can't open_desc_in fail for example ?
gim has quit []
<urz> i could jsut use this function:
<urz> CAMLprim value caml_open_descriptor_in(value fd)
<urz> {
<urz> return alloc_channel(open_descriptor_in(Int_val(fd)));
<urz> }
<urz> but then i need to convert my fd into an ocaml integer first
<urz> heh
<urz> These functions can be called directly from C.
<urz> No locking is performed. */
<urz>
<urz>
<urz> CAMLexport struct channel * open_descriptor_in(int fd)
<urz> would No locking be an issue?
<mattam> i don't think so
<urz> looking at the code, it actually does an lseek on the file
<mattam> open_desc ?
<urz> its most likely stdin
<urz> yes it does
<urz> channel->offset = lseek (fd, 0, SEEK_CUR);
<urz> theres no way for open_desc to fail unless its a failed memory allocation or that lseek failed
<urz> it does no checking on either of those
<urz> anyway, the segfault doesnt happen till its time to oldify
<urz> i am using a few global variables too
<urz> should i register_global_root() before or after assigning data to the variable? does it make any difference?
<urz> hm, channels are kept in a linked list
<mattam> they have a refcount too
<mattam> didn't know that
<urz> well i dont see any problem
<urz> it hapens when they oldify localroots
<urz> maybe its realted to my global variables
<urz> I initialize my global variables with Val_unit no matter what data type i eventually store in them, maybe thats the problem
<urz> oh, i didnt use CAMLlocal1 to decalare a variable
<urz> and its the variable i assigned to and returned to ocaml
<urz> i declared it directly with "value c;"
<mattam> that caused the segfault ?
<urz> i dont know
<urz> its not like the segfault happens at any particular time
<urz> so i have to let my program sit and run for a long time
<mattam> good luck then, and good night!
<urz> Fatal error: exception Invalid_argument("String.create")
<urz> heh
<urz> now i have to track that down
<urz> i dont know what that means
<urz> a number too large to allocate a string or a negative number or what?
<urz> oh i found it
<urz> is there a max function builtin to ocaml?
<urz> for integers?
maihem has joined #ocaml
<urz> it segfaulted again
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
Lemmih has joined #ocaml
bzzbzz has quit [Ping timeout: 14400 seconds]
<urz> do i need to use alloc(1,0) to allocate space for a single value?
cjohnson has joined #ocaml
GreyLensman has joined #ocaml
cjohnson has quit [Remote closed the connection]
monotonom has quit ["Don't talk to those who talk to themselves."]
vezenchio has joined #ocaml
GreyLensman has quit ["Leaving"]
bzzbzz has joined #ocaml
vezenchio has quit ["look at you, hacker, a pathetic creature of meat and bone, panting and sweating as you run through my corridors; how can you ]
vezenchio has joined #ocaml
Iter has quit [Read error: 110 (Connection timed out)]
bzzbzz has left #ocaml []
n_i_c_o27a has joined #ocaml
n_i_c_o27a has left #ocaml []
cedricshock has joined #ocaml
<Banana> urz: i think you need to use the CAMLparam() CAMLLocal and CAMLReturn macro in you C function.
<urz> heh
<urz> i know
<Banana> is the segfault pb solved ?
<urz> it was apparently connected with my making a channel from an fd and sending it to ocaml
<urz> its bindings for readline
<urz> readline allows you to provide your own getc function but it is supposed to take a FILE *
<urz> in my program that i'm using readline for, my getc function ignores the argument anyway, so i scrapped that code
<Banana> he he.
<Banana> good job in tracking this kind of bug down :)
<Banana> brb/
cedricshock has quit ["Leaving"]
buggs has joined #ocaml
<wolfman8k> is NML any good?
<Banana> the corean thing ?
<wolfman8k> "Numerical ML" or something
<wolfman8k> btw, Chris Hecker is involved with OCaml? :O
gim has joined #ocaml
<Banana> wolfman8k: where did you see that ?
<Banana> seems interesting.
<wolfman8k> it appears to be dead though
mrsolo has joined #ocaml
_fab has joined #ocaml
<wolfman8k> how does one add types to the language?
<Banana> you mean user defined type ?
<wolfman8k> yes
<Banana> type my_type = type-expression
<simon-> type atype = A | B ;;
<Banana> (it's a bit simplified).
<ayrnieu> also, you read the O'Caml book.
<wolfman8k> hm... ok thanks guys
<simon-> wolfman8k, if you're reading a tutorial, I'm sure it will get to it
<wolfman8k> no, i just read this paragrah from a mailing list archive:
<wolfman8k> I will say- there is a way to get both the ease of development of operator overloading *and* the performance of BLAS. Make matricies first class types known to the compiler, like ints, floats, and strings (vectors can be considered m-by-1 matricies). Now the compiler knows what substitutions are legal or not- it can easily replace a = b + c + d; with a = b; a += c; a += d;, or even a = d; a += c; a += b; if it feels like it.
* simon- reconsiders that he uses pronouns a lot
<Banana> hum...
<Banana> these is another kind of type definition.
<Banana> in this case one want to extend the type system to add a first class type...
<Banana> you need to hack the ocaml compiler to do that...
* wolfman8k cries
<wolfman8k> he goes on to say:
<simon-> wolfman8k becomes wolfman7999
<wolfman8k> The compiler would then produce code which would call out to a library which would have to be linked in (rather like you have to add -lm to your command line to use sin() in C). So programs which don't use matricies don't have to suffer the "code bloat" associated with them.
<Banana> he is talking about ocaml ?
<simon-> what code bloat? isn't that just a matter of how fast the compiler compiles?
* Banana is going to scream (© X.Leroy).
* simon- keeps quiet :)
<Banana> i think people should be aware that ocaml is meant as a generic language which needs a small and well defined kernel so that you don't run into bootstraping issues.
<wolfman8k> the problem is that syntax can get very ugly for numerical stuff
<Banana> then use camlp4 to beautify it.
<Banana> or any preprocessor you want.
<wolfman8k> i read that camlp4 isn't powerful enough
<Banana> ...
<wolfman8k> this was back in 2002 though
<Banana> if it's a syntactic problem only then camlp4 should be more than enough.
<ayrnieu> I read that camlp4 has astonishing power, before 2002 even. I guess that one of us will just have to try it and see -- and I've other things to do right now.
<Banana> if it involves typing and optimising of cours camlp4 cannot do this.
<wolfman8k> i think it does involve typing
<wolfman8k> anyway, i'll just live with the syntax for now. thanks guys
cedricshock has joined #ocaml
karryall has quit ["tcho"]
mrsolo has quit ["Leaving"]
<cedricshock> I'm new to OCaml. Is there any way to do something like an eval?
gim has quit []
<mellum> cedricshock: no
<ayrnieu> cedric - if you enjoy Haskell and O'Caml, as you seem to, and you also want a dynamic language (e.g., with eval, runtime code update, program's-own-extension-language, etc), please consider Q (http://q-lang.sf.net/) and Erlang.
<cedricshock> ayrnieu: I've been playing with Erlang. Perhaps it has made me a little biased.
<ayrnieu> cedric - the first time you develop a complex server from 'ooh, it listens to a port!' to 'ooh, it has 500 users right now!' (for an extreme case =) without ever stopping your initial server process, it will bias you very very much.
urz has quit ["."]
<cedricshock> ayrnieu: All I really want is one tiny little feature. Most languages have some way to take a text representation of an integer and turn it into a full fledged working integer. All of these functional languages say they treat functions as first class objects. I want the direct analog - taking a text representation of a function and using it as the full useful object. It seems necessary in order to say that functions are treated on par w
<cedricshock> ith other objects.
* ayrnieu shrugs. Not an uncommon desire, nor an uncommon feature.
<cedricshock> Great. Must I look to a dynamic language to find it?
<ayrnieu> Yes, of course.
<cedricshock> Ok. I give up. Eventually, when I am in control of billions of dollars of assets (working on open source stuff is going to take me there, right?), I will have the resources to hire people to solve all these small little problems that I don't have the interest in to do myself.
<ayrnieu> Give up on what?
<cedricshock> Actually the hs-plugins thing is pretty close - it is exactly what would be needed for a non-"dynamic language", a compiler. It could be quite a few steps shorter though, and all wrapped up in one or two functions.
<cedricshock> Maybe I need new words to direct my searching. "Run-time compilation" sounds good. I'll try that.
<ayrnieu> O'Caml also has something, apparently, given its Emacs-like 'efuns' and toplevel building.
<ayrnieu> cedric - or you could just ask me what you look for.
<cedricshock> Here is what I look for:
gl has left #ocaml []
gl has joined #ocaml
<cedricshock> A language with:
<cedricshock> A whole bunch of data types, each of which can be converted back and forth between some meaningful string representation, and optionally may also be converted into some other more efficient serialized representation. This set of data types needs to include a function or some other sort of procedural object.
<cedricshock> Bindings to some nice, simple, powerful gui system, in some manner consistent with the design of the language
<ayrnieu> and also with an open-source implementation?
<cedricshock> Prefferably, or something I can afford.
<ayrnieu> cedric - you may want to consider REBOL, then.
<cedricshock> And also be reasonably small, and reasonably fast
<cedricshock> Erlang actually fits this description pretty well, but its kind of big.
<ayrnieu> REBOL has a considerably simpler graphical system, and a much much smaller system. I wouldn't call Erlang 'big' as I would call it 'an operating system'.
<ayrnieu> and I wouldn't call it that to slight it; you just have to recognize that 'erl' boots up an operating system if you want to avoid the madness of trying to treat it like a normal unix program.
<cedricshock> ayrnieu: exactly. Erlang is an operating system. That's what I meant by big. I should have said any programming language that needs you to write bootup scripts at some point ...
<ayrnieu> well, Erlang's operating-system-ness doesn't really mean 'big'. It means that it has unusually big points and unusually small points -- for instance, most people compile a C 'hello world' to 3K and think they have something really small and quick-loading, when they in fact just have a gigantic support system (ld.so, libc.so, kernel magic, innumerable 'OS' setup) to support that binary.
<cedricshock> I didn't mean to slight Erlang. I think, at the moment, it is my favorite programming language. I should probably stop poking around for something else, bite the bullet, and tackle the real problem that is keeping me from getting anywhere on this poject - the architecture of the program.
<vezenchio> you could write a really small hello world program in C that does NOT rely on any external library support at all, depending on the target platform
<ayrnieu> vezen - sure, and you could write a tiny OS.
<vezenchio> well im just saying, in response to the "people think a C hello world is really small" comment
<vezenchio> because really a hello world program in ANY language is pretty much just going to consist of a stack-push of the adress of a string followed by a call to a library "print" routine
<ayrnieu> vezen - just pointing at the oft-unlooked C Runtime Environment =)
<ayrnieu> also, overlooked.
<vezenchio> yeah but that was not a very good example, because any programming language is going to have a print function in a default library somewhere
<ayrnieu> but I don't think of Erlang programs as so, big, anyway, because I always have at least two nodes running at any time.
<cedricshock> I havn't gotten past one node. Really, what's the difference? Erlang makes tow nodes behave almost exactly like they're one.
<ayrnieu> cedric - I didn't read you as slighting Erlang. I've just thought some about this, already =) er, no difference -- one node runs as a different unix user and manages services such as Yaws; the other runs as my casual user and connects with distel, hosts normal programs, and so on. I sometimes like, for no particular reason, to have a 'developing' node and a 'services' node.
<ayrnieu> not by those names =)
<ayrnieu> anyway, please don't forget to consider Q.
mattam_ has joined #ocaml
<cedricshock> My project is a programming language (sort of), so it is primarily a user interface problem. However the user interface problem also involves the conceptual problem of how to present data and algorithms. The idea is to have objects mapped to each other through some sort of morphisms. The most basic object would be some space that is the cartesian product of a bunch of categories, and a morphism being some definition of a new space someh
<cedricshock> ow based on a previous one.
<cedricshock> I guess some sort of meta object would be necessary to do things like combine data from multiple source objects.
<cedricshock> Borrowing terms from my recently aquired touch of category theory and arrows, and using them to describe what I had concieved)
kinners has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
<cedricshock> Then plus all the goodies of higher order functions, symbol manipulation, unit conversions, anova statistics, and many different types of data displays. At least, thats the idea.
_fab has quit []
kinners_ has joined #ocaml
kinners has quit [Read error: 60 (Operation timed out)]
mij has quit [Read error: 104 (Connection reset by peer)]
bk_ has joined #ocaml
maihem has joined #ocaml
cedricshock has quit ["Leaving"]
_fab has joined #ocaml
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
_fab has quit [Read error: 60 (Operation timed out)]
_fab has joined #ocaml
mij has joined #ocaml
<p0lartype> is there arithmetic in lambda calculus, except church integers ?
cjohnson has joined #ocaml
Smerdyakov has quit ["go airplane"]
kinners_ has quit [Read error: 113 (No route to host)]
mattam_ is now known as mattam
<Banana> p0lartype: you can encode any decidable arithmetic in lambda calculus but there is no arithmetic 'in se' in the lambda calculus.
<mellum> in se?
<Banana> in itself
<p0lartype> Banana: are you kim nguyen ?
<Banana> i am.
<p0lartype> you're a crypto guy right
<mellum> you mean "per se"?
<Banana> HA HA HA.
<Banana> not at all.
<Banana> there are like bilions of kim nguyen on earth you know ?
<Banana> ;)
<p0lartype> ;)
<Banana> I'm a french graduate student.
<Banana> mellum: yes my latin is worst than my english.
<Banana> :)
<gl> "crypto guy"
<gl> haha
<wolfman8k> is F# any good?
<simon-> heh
<simon-> I'd say it depends on how much they continue to copy from ocaml, but I haven't tried it :)
<vegai> if you have to do .net, it probably is quite good
<wolfman8k> and if not?
<vegai> well, why bother
<simon-> then why bother using a .net component?
<wolfman8k> eaiser to work with other languages?
<simon-> it probably has its integration into windows so you may have some beneg
<simon-> fits
<simon-> (I'm learning dvorak, bear with me :-)
<wolfman8k> guess i'll just stick with plain OCaml then
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
<wolfman8k> hm... what is the best way to work with loading/saving with OCaml? XML?
<Lemmih> It depends on what you wanna load/save.
<wolfman8k> custom data structures
<Banana> then use the marshalling functions of ocaml.
<Banana> (with care).
maym has joined #ocaml
<wolfman8k> hm... are the file compatible between architecturse?
monotonom has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
mrsolo has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
<Demitar> wolfman8k, Marshal is good for caching, not real storage. You might want to check out the camlp4 extension for generating xml writers and readers for data structures.
cedricshock has joined #ocaml
Submarine has joined #ocaml
bk_ has joined #ocaml
vezenchio has quit ["look at you, hacker, a pathetic creature of meat and bone, panting and sweating as you run through my corridors; how can you ]
<wolfman8k> ...challenge a perfect, immortal machine?"
fox___^ has joined #ocaml
<buggs> run ???
<wolfman8k> hm?
fox___^ has left #ocaml []
Lemmih has quit [Remote closed the connection]
foxster has joined #ocaml
maym has left #ocaml []
Iter has joined #ocaml
monotonom has quit ["Don't talk to those who talk to themselves."]
cjohnson has quit [Read error: 60 (Operation timed out)]
<wolfman8k> what is a .cmx file?
<wolfman8k> and .cmo?
<ayrnieu> native-compiled and byte-compiled, respectively, IIRC. I probably don't RC.
<Submarine> Indeed.
<Submarine> .cmi is compiled module interface
<wolfman8k> compiled what?
<wolfman8k> hm...
<Submarine> .cmo is compiled module object
<Submarine> .cmx is compiled module object, native code
<wolfman8k> i'm getting this error:
<wolfman8k> No implementations provided for the following modules:
<wolfman8k> IoXML referenced from foo.cmx
<wolfman8k> problem is there is no ioXML.cmx file
<Submarine> Well, what is IoXML supposed to be?
<Submarine> Certainly not a standard module. :-)
<Submarine> .cmx files can be grouped in .cmxa files
<wolfman8k> i only have ioXML.* : cmi cmo cmx mli o
<Submarine> do you have ioXML.cmx?
<wolfman8k> yes
<Submarine> well: ocamlopt ioXML.cmx foo.cmx -o foo
<wolfman8k> that seems to work =) but how can i get it to work in OCamlMakefile?
<Submarine> No idea, I don't use OCamlMakefile.
* Submarine writes his own makefiles by hand.
<bk_> ocamlbldflags and ocamlnldflags
* Submarine is conservative.
<wolfman8k> thanks!
cedricshock has quit ["Leaving"]
cedricshock has joined #ocaml
* wolfman8k can't figure out what this means:
<wolfman8k> type ('a, 'b) bar = Leaf of 'a | Node of 'b * ('a, 'b) bar * ('a, 'b) bar ;;
<mattam> leaf contain 'a objects and nodes 'b object
<mattam> s
<mattam> and have two sons too
* wolfman8k 's head explodes
<Submarine> well it's easy
<Submarine> leave out 'a and 'b
<Submarine> type bar = Leaf of a | Node of b * bar * bar;;
<Submarine> a "bar" is either a Leaf with one constituent a, either a Node with three consistuents: a b, a bar and a bar
<wolfman8k> ok, i think i need to read over that tutorial again a few more times
GreyLensman has joined #ocaml
<wolfman8k> ok, i think i got it. what is the correct syntax for something like this:
<wolfman8k> let v = (Node "boo") (Leaf 1) (Leaf 2)
<Submarine> let v = Node("boo", (Leaf 1), (Leaf 2))
<wolfman8k> ah, makes sense. Thank you
<Submarine> binary search tree?
<wolfman8k> not sure
<wolfman8k> that is definetly one powerful line of code though
<wolfman8k> in C++ it would be maybe 10 lines
<Submarine> wait until you write tree traversal
<Submarine> in C++ you'd probably have to write iterators and transducers in template form
<Submarine> (like the System F encoding of inductive types, if you see what I mean)
<wolfman8k> hm... so how would one, like traverse the tree and print out all the values of the leafs? (order isn't important)
<Submarine> let rec traverse = function Node(_, left, right) -> traverse left; traverse right | Leaf(x) -> print_string x;;
<wolfman8k> whoah, it works. cool :D
<wolfman8k> thanks man for all the help
<wolfman8k> ocaml is starting to look good :)
ez4 has joined #ocaml
<wolfman8k> anyway, i gotta go to sleep
<bk_> n8
Tachyon76 has joined #ocaml
ez4 has quit ["Download Gaim: http://gaim.sourceforge.net/"]
wolfman8k has quit ["sleep"]
mrsolo has quit [Read error: 110 (Connection timed out)]
cedricshock has quit [Remote closed the connection]
Tachyon76 has quit ["Leaving"]
Anvil_Vapre has joined #ocaml