Banana changed the topic of #ocaml to: OCaml 3.08.1 available! | Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ | 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/
jason has joined #ocaml
<jason> Hm, I'm reading a bit about Streams, and it claims that they can be constructed via : [< >];;
<jason> .. But, even after opening the Stream module, it still doesn't recognise [< >];;
cjohnson has joined #ocaml
jason has quit [Remote closed the connection]
nysin has quit ["leaving"]
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
ez4 has joined #ocaml
mrsolo_ has quit [Read error: 104 (Connection reset by peer)]
kinners has joined #ocaml
CosmicRay has joined #ocaml
CosmicRay has quit [Client Quit]
CosmicRay has joined #ocaml
mrsolo_ has joined #ocaml
fab__ has joined #ocaml
cjohnson has quit [Connection timed out]
cjohnson has joined #ocaml
salo has quit []
_fab has quit [Read error: 110 (Connection timed out)]
cjohnson has quit [Read error: 104 (Connection reset by peer)]
CosmicRay has quit ["Leaving"]
kinners has quit ["leaving"]
Smerdyakov has quit ["Client exiting"]
Smerdyakov has joined #ocaml
ez4 has quit [Remote closed the connection]
vezenchio has joined #ocaml
jason has joined #ocaml
salo has joined #ocaml
<jason> How would I go about making an Ocaml topend that had a specific ocamlp4 preprocessor filter in place?
<jason> I tried ocamlmktop -pp "ocamlp4o <fliter>" -I +camlp4 -o top
<async> mkcamlp4?
<Demitar> Well, I don't think you do. Since ocamlp4o is a preprocessor...
<async> signed and unsigned addition/subtraction are identical, right?
<jason> mkcamlp4 makes a camlp4 exec right?
<jason> Are there signed and unsigned datatypes?
<jason> They're different from the perspective of assembly, I know.
<async> are they>
<jason> Yes.
<jason> From the perspective of assembly.
<Demitar> Yes it does. The best solution is probably to compile a buffer.
<async> what are two numbers that give different results using add and addu?
<async> in terms of the bits
<Demitar> jason, all numbers are signed.
<jason> Demitar: In Ocaml.
<jason> I think he's asking a more general question.
<Demitar> Yes in ocaml.
Blicero__ has joined #ocaml
<jason> Is a function with a match branch that recursively calls itself tail recursive if it's the last call in that specific branch?
<jason> .. That sentence could have use a bit of punctuation :)
<mflux> it is even if it wasn't last?
<jason> .. What do you mean?
<mflux> uh, I thought you meant the last match in the match but obviously you meant the match itself
<jason> I want to know if it is still tail recursive.
<mflux> let foo n = match 0 -> () | n -> foo (n - 1);; is tail recursive
<jason> Like, "let rec bob x = match x with Blah y -> bob y | None -> x;;
<jason> Something like that, is it still tail recursive, even though there are other possible branches?
<jason> .. Not the other way around?
<jason> It has the be the last match?
<mflux> the point to consider with tail recursiveness is that will the function that makes the call have any instructions left after the called function returns
<jason> Right.. And I could potentially do both with matching though.
<jason> I could have one branch that 'is' technically tail recursive, and another than isn't.
<jason> I'm trying to think of how it would generate code for such a possibility.
<jason> How could it make a statement that used a jump and a function call?
<mflux> it's not that complicated
<mflux> instead of storing current stack frame it just doesn't have to
<jason> I understand tail recursion.
<jason> let rec x m = match m with Bob y -> x y; x+1 | Joe y -> x y;
<jason> So, in this case, one branch of the match 'is' tail recursive, while the other isn't.
<Blicero__> whats the significant differences between sml and caml?
<jason> So, if it doesn't know which branch it is going to take, it will have to store the previous environment in case it ends up in the other non-tail recursive branch.
<jason> Or, am I missing something?
<jason> Objects, SML has different syntax.
<jason> Some different syntax.
<jason> Very similar.
<Blicero__> well, in terms of advantanges? what is one better at than the other?
<jason> Ocaml has a better compiler.
<Blicero__> thanks
<jason> I'm not really willing to say which is 'better'.
<mflux> jason, I would expect it to store the environment always and then just overwrite it
<mflux> I haven't looked at the code ocaml creates though
<jason> mflux: What if it ends up in the branch that could potentially use the previous environment though?
<jason> mflux: I've looked at some of the asm it produces, it's surprisingly readable.
<mflux> jason, make the decision at the point you make the jump?
<jason> mflux: In comparison with what C generates :)
<Blicero__> yeah i wasnt exactly asking which was 'better'
<mflux> at each function call, check if there's code after, if not, optimize
<jason> Hm.
<jason> Yeah, but with a match the function call is bimodal, it ends differently.
<jason> It could end tail recursively, where as the compiler would write over the environment on the stack and jmp, or non-tail recursive where you'd expect it to store the environment.
<mflux> hmm.. example?
<jason> let rec x m = match m with Bob y -> x y; x+1 | Joe y -> x y;
<jason> Something like that.
<jason> Well.. Hm.
<jason> Wait a sec.
<Blicero__> why does ocaml need two chars for end of line
<jason> I'd have to make it a bit more complicated to make it possible for the value to return type Joe :p
<mflux> well, for that case how about pseudo-c-code like value x(value m) { if (m.type == Bob) { value v = x(m.value); return v + 1; } else { jump x(m.value); } }
<jason> Hm, okay.
<jason> That makes sense.
<jason> Smart compiler :)
<jason> I suppose strings aren't null terminated, and they possible want to leave open the possibility they could be terminated with \r\n.
<jason> Ahem, by terminated I don't mean string terminated, but line terminated.
<jason> I have to say this "Developing Applications with Objective Caml" book is probably the best programming book I've ever read.
<jason> Much more concerned with teaching programming concepts than just language syntax.
<Blicero__> how are function calls grouped?
<jason> What do you mean?
<jason> In the binary?
<Blicero__> if you had a function call inside a function call that looks like f(g(x),y) in a c-like language, how does it look in caml
<jason> let myFunc x = let otherFunc y = y+5 in otherFunc 6;;
<jason> Something like that.
<mflux> maybe he just means: f (g x) y
<jason> Well, otherFunc x :p
<jason> Oh, internally.
<jason> Yeah.
<jason> It basically evaluates g x and passes the result to f.
Herrchen has joined #ocaml
<Blicero__> alright so () groups
<jason> Right.
<jason> Like in C.
<Blicero__> yup
<jason> If g took two arguments, you could pass a partially completed g.
<Blicero__> oh, currying?
<jason> Right.
<Blicero__> neat
<jason> So, why doesn't the type inferance mechanism work with class definitions?
simon has joined #ocaml
jason has quit [Remote closed the connection]
DerDracle has joined #ocaml
<DerDracle> Hm, what is the default size of the heap for a ocamlopt compiled executable?
<DerDracle> I keep getting Out of Memory errors.
<mflux> is there any heap size limit in them?-o
<DerDracle> I'm not sure :p
<DerDracle> That's what I'm asking.
<DerDracle> Hehe.
<DerDracle> I'm trying out this MLGame stuff.
<DerDracle> And almost every one of the examples gives me an Out of Memory error.
<DerDracle> I really hope it isn't consuming all 256 MB of my RAM.
<mflux> maybe your ulimit is something ridiculous. although that would be weird.
<DerDracle> Hm, Unlimited.
<DerDracle> Stack size max = 8192
<DerDracle> 8192 what?
<mflux> kilo bytes
salo_ has joined #ocaml
salo has quit [Remote closed the connection]
salo_ has quit [Remote closed the connection]
salo has joined #ocaml
mrsolo_ has quit [Read error: 110 (Connection timed out)]
mrsolo_ has joined #ocaml
DerDracle has quit [Remote closed the connection]
salo has quit [Remote closed the connection]
salo has joined #ocaml
kinners has joined #ocaml
salo has quit [Read error: 110 (Connection timed out)]
salo has joined #ocaml
salo has quit [Client Quit]
srv has joined #ocaml
srv_ has quit [Read error: 232 (Connection reset by peer)]
salo has joined #ocaml
kinners has quit ["zzzz"]
haakonn has quit [Read error: 104 (Connection reset by peer)]
haakonn has joined #ocaml
haakonn has quit [Read error: 110 (Connection timed out)]
haakonn has joined #ocaml
<oracle1> oh
<oracle1> the cook book was being updated
urz_ has joined #ocaml
<urz_> hm
urz_ has quit [Client Quit]
monochrom has joined #ocaml
salo has quit []
pango_ has quit [Read error: 104 (Connection reset by peer)]
haakonn_ has joined #ocaml
pango has joined #ocaml
docelic has joined #ocaml
<haakonn_> i define a record type in one module, then open that module in another module, and declare a record instance with all the field labels. ocamlc says "Unbound record field label pos_filename". can't i import types like that?
docelic has quit ["Quit"]
salo has joined #ocaml
docelic has joined #ocaml
<avlondono> yes you can. there is some other error.
Herrchen has quit ["bye"]
<haakonn_> ok, hm.
<haakonn_> i see, the type isn't defined in the .mli file, and i can't define it there since the mli is generated by ocamlyacc :(
<haakonn_> have to go, direct any further assistance to haakonn :)
haakonn_ has quit ["leaving"]
cjohnson has joined #ocaml
Tristram has joined #ocaml
shulik_ has joined #ocaml
shulik_ has left #ocaml []
Blicero__ has quit ["Leaving"]
haakonn_ has joined #ocaml
vezenchio has quit ["None of you understand. I'm not locked up in here with you. YOU are locked up in here with ME!"]
haakonn has quit [Read error: 110 (Connection timed out)]
CosmicRay has joined #ocaml
salo has quit []
zigong has quit [Read error: 110 (Connection timed out)]
mrsolo_ has quit [Connection timed out]
ez4 has joined #ocaml
fab__ has quit []
CosmicRay has quit ["Leaving"]
salo has joined #ocaml
<salo> is it true that ocaml classes can have only exactly one constructor?
<Smerdyakov> Yes
<salo> do paramaterized classes facilitate a way around that that i haven't quite figured out yet ?
<Smerdyakov> No, but since OCaml has variants, you can make a variant with a case for each "separate constructor" you're wishing for.
<salo> ahhh, i think i understood that. thanks again!
<Smerdyakov> It's also likely that you can make a separate class for each "separate constructor."
<Smerdyakov> OCaml doesn't distinguish at all between classes with identical interfaces.
<Smerdyakov> Even better, don't use OO.
<Smerdyakov> Most seasoned OCaml'ers rarely use it.
<salo> well i have been exploring it to get around the lack of eval, and so far it seems promising.
<Smerdyakov> Can you explain your situation in more detail?
<salo> if you are interested to hear it, i'd be glad to explain what i am up to. are you familiar with genetic programming, particular the grammatical form?
avlondono has quit [Read error: 104 (Connection reset by peer)]
<Smerdyakov> I have heard of GP, but not "the grammatical form."
<salo> all that is meant by that is the genotype is an expression in a formal grammar
<salo> that is, an individual trial solution is a symbolic expression
avlondono has joined #ocaml
<salo> now i am interested in porting my generic evolutionary programming system from scheme to ocaml, because i am interested in ocaml for its own sake, and because it scores uniformly very high on benchmarks, particularily numerical ones
<Smerdyakov> OK.
<salo> and the problems that i am working on involve very large matrix algebra and seminumerical optimization algos
<salo> so, i am trying to figure out the "ocaml way" to parse symbolic expressions
<salo> in such a way that i do not have to touch the parser when i add new functionals or terminals to my expressions
<Smerdyakov> What does it mean to "add a functional to expressions"?
<salo> symbols which represent functions. i am probably misusing that term
<Smerdyakov> Why don't you just represent these symbols as the functions themselves?
<salo> does ocaml have run time inspection of functions? can i ask a function what its label is, and what type of input it wants?
<Smerdyakov> You can represent functions as pairs of their names and the functions themselves.
<Smerdyakov> You can also have a variant for the different types of functions you are considering.
<salo> can i find out the type of input a function wants at runtime?
<Smerdyakov> No
<Smerdyakov> Even if you could, there would be no way to call it.
<salo> this is why i was considering using objects, since they can contain this info and self describe themselves at runtime
<Smerdyakov> No.
<Smerdyakov> They offer no more than a non-OO solution.
<Smerdyakov> Perhaps you can be more concrete about what kinds of functions you mean to allow?
<salo> my goal is to be completely generic
<Smerdyakov> What does that mean? You want to allow arbitrary OCaml code in your inputs?
<salo> i am trying to come up with a clear explanation
<salo> perhaps if you understand scheme it would be easier to talk about what i do now in scheme
<salo> the difficulty so far has been how to structure the parser such that it can be extensible without having the end user add code to the parser
<Smerdyakov> I am familiar enough with Scheme, I think.
<salo> with scheme i can simply use eval as the parser, and make global definitions for the function symbols which appear in the expression
<salo> if i want to use a new grammar, i just provide definitions for the new function symbols
<Smerdyakov> You can provide your own mapping from strings to functions in OCaml.
<salo> i think i see your point. then the parser isn't quite as nice, since it has to go looking into some association list as opposed to using a match block. but it wouldn't require the end user to modify the parser
mayhem has quit [Read error: 60 (Operation timed out)]
<vincenz> what you can also do
<vincenz> is instead of having strings of characters, having strings of symbols
<vincenz> which represent your different possible actions in your expressions language
<salo> symbols?
<vincenz> I mean you're doing GP, you don't have to go down to the textual level to represent your expressions
<vincenz> yes
<vincenz> type exp = Add | Mul | ...
<vincenz> and then a string would be a string of these symbols
zigong__ has joined #ocaml
<salo> ohhh, i see. types themselves can be used in a similar fashion to scheme symbols. interesting!
<vincenz> well if you look at it, it's quite clear
<vincenz> scheme's language (well lisp originally)
<vincenz> was designed to do away with parsing
<vincenz> and work directly in the AST form
<vincenz> jsut cause scheme does it with real text doesn't mean you have to
<vincenz> you can use symbols
<vincenz> going to full text seems a bit overkill for what you're doing
<vincenz> after all I assume you only allow mutations that reslut in valid expressions
<vincenz> which means you'll have to do mutations on the symbol-level and not textual level
<salo> grammatically valid yes, but not semantically valid
<vincenz> right
<vincenz> iso working with symbols is the level you want
<salo> instead of strings of symbols, list of symbols is also viable, no?
<vincenz> yup
<salo> neat. thanks!
<salo> can anyone elucidate the use of the Set module?
<Smerdyakov> Have you used Set in Java?
<salo> many years ago perhaps
<Smerdyakov> Do you know how to use functors?
<salo> no, i'm afraid i do not
<Smerdyakov> Then you should read the tutorial in the OCaml manual.
<Smerdyakov> You'd do well to read the whole thing, so you are aware of all the main language features
<salo> i have been reading it quite a bit. modules and functors are rather outside my previous experience
<Smerdyakov> That shouldn't be a problem. Are you saying that the manual is unclearly written?
<salo> no, its not bad
mlh has joined #ocaml
<salo> perhaps if you wouldn't mind showing me how to construct an integer set, it would accelerate my understanding
<Smerdyakov> Well, it would be better if you understood functors in general. There is nothing unique or hard about how the Set module works.
<Smerdyakov> I'll ask again: Are you saying that the tutorial section on functors is too hard to understand?
<salo> perhaps i am looking in the wrong part of the manual, but the bank account example is rather large for a simple first example
<Smerdyakov> You're certainly looking at the wrong part, since Set is the example for functors in the tutorial. :D
<Smerdyakov> It's the tutorial at the very beginning of the official manual.
* salo looks
kinners has joined #ocaml
<salo> do modules and classes serve different purposes? they seem to have significant overlap
<kinners> salo: classes give you late binding basically
<salo> gotcha
<kinners> salo: there's a description of the overlap & differences somewhere (by X.Leroy?)
<haakonn_> if i define a record type in one .ml file which i open as a module in another .ml file, is that type not imported? does it have to be defined in an .mli or something instead?
<Smerdyakov> haakonn_, it is imported...
<haakonn_> ok ... i must be doing something strange, hm.
<Smerdyakov> haakonn_, naturally, if the imported module has a .mli file that doesn't mention _any_ component, record type or otherwise, that component will be hidden.
<haakonn_> ah, i see, it's simply hidden, then. too bad you can't do anything about the mli files ocamlyacc generates