dylan changed the topic of #ocaml to: OCaml 3.09.1 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
<dozer> hump - still can't make it work, even with fold_right - the types are wrong
<dozer> trying to do something much more like ('a -> 'a -> 'b) -> 'a list -> 'b
<mikeX> lists can't contain elements of different types, tuples and records can however, not sure if that's what you wanted
<vodka-goo> dozer: what's the initializer of your folding in that type ?
<vodka-goo> your first arg is a function which adds an elem to the return value, it has to have a value to which the first elem will be added
<mikeX> oh, now I see what you meant
<dozer> ok ... trying something else
bohanlon has quit ["Leaving"]
<pango> It's probably more natural to convert it to Op(w, Op(x, Op(y, Op(z, Nil))))
<pango> it requires 2 cases instead of 3
<pango> and empty list will be a valid input value
<pango> that's how lists are implemented btw... [w; x; y; z] = w :: x :: y :: z :: []
Skal has quit [Remote closed the connection]
humasect has joined #ocaml
<dozer> is there a short-hand for something like: function x -> function y -> Dot(item, x, y)
<dozer> I tried function x y -> Dot(item,x,y) and also function x->y-> Dot(Item,x,y) but got syntax errors
<mikeX> what exactly is Dot?
<mikeX> you have to write fun x y,
humasect has quit ["Leaving.."]
<vodka-goo> function actually takes patterns (so takes only one arguments)
vodka-goo has quit ["Connection reset by by pear"]
bohanlon has joined #ocaml
bohanlon has quit [Remote closed the connection]
bohanlon has joined #ocaml
Revision17 has quit [Remote closed the connection]
dozer has left #ocaml []
b00t has joined #ocaml
slipstream-- has joined #ocaml
b00t has quit [Remote closed the connection]
slipstream has quit [Read error: 110 (Connection timed out)]
quamaretto has quit [Remote closed the connection]
pango_ has joined #ocaml
pango has quit [Read error: 145 (Connection timed out)]
zigong has joined #ocaml
zigong has quit [Client Quit]
zigong has joined #ocaml
SKerjean has joined #ocaml
<SKerjean> hello !
<zmdkrbou> fuck
* zmdkrbou 's drunkl
<dylan> is drunkl anything like foldl?
<dylan> >:)
* zmdkrbou 's like fold
* zmdkrbou "s jsut drunk
<dylan> Must be good stuff.
<zmdkrbou> yeo
<zmdkrbou> yep*
<dylan> May I ask what?
<zmdkrbou> what what ?
<dylan> What you're drunk on.
<zmdkrbou> i'm drunk on life is shit
<zmdkrbou> vodka is your friend when life is shit
* zmdkrbou kisses vodka-goo
<dylan> No, life is 42. shit is 5417.
* zmdkrbou fucks 54176
<zmdkrbou> -6
<zmdkrbou> putain de sa mère
<zmdkrbou> ya que des putains de francais ici en plus
<SKerjean> zmdkrbou quel langage...
<zmdkrbou> ahah j'ai raison
<zmdkrbou> oui
<SKerjean> zmdkrbou un britto-autrichien installe au quebec ca fait l<affaire ?
<zmdkrbou> langage de merde
<zmdkrbou> SKerjean: ca me va :)
* zmdkrbou fait un bisou a SKerjean
<SKerjean> zmdkrbou tu sais personne t'embetera ici d'ou que tu vienens
<zmdkrbou> je sais
<zmdkrbou> spour ça que je cause
<zmdkrbou> ici c'est cool
* zmdkrbou fucks la vie
<zmdkrbou> en plus jmen branle
<zmdkrbou> i don't even get shamed
<zmdkrbou> vodka-goo and ppsmimou are not there
bzzbzz has joined #ocaml
<zmdkrbou> ya bzzbzz
<zmdkrbou> ca va ?
<SKerjean> tu apprends ocaml ?
<zmdkrbou> huhu
<zmdkrbou> non ça va ça fait quelques temps que je connais
<zmdkrbou> ou alors on me parle pas ?
* zmdkrbou légèrement beurré
<zmdkrbou> bzzbzz: hého
<SKerjean> ok
zigong has quit ["using sirc version 2.211+KSIRC/1.3.12"]
<zmdkrbou> SKerjean: tu parlais à moi ou bzzbzz ?
<SKerjean> tu utilises les facilites objet du langage ? (A toi zmdkrbou)
<zmdkrbou> euh non moi je suis allergique aux objets :)
<zmdkrbou> pour de vrai
* zmdkrbou fait du caml de base, est content
* zmdkrbou devrait se mettre à haskell
* zmdkrbou est un facho du fonctionnel
zigong has joined #ocaml
<SKerjean> zmdkrbou ok moi j<aime bien les objets on fait delirer le systeme de typage avec :)
<zmdkrbou> lol
<zmdkrbou> clair le typage ça part en couilles avec les objets :D
<zmdkrbou> spire que coq tellement c'est le bordel
<SKerjean> ben y a de la quqntification c'est marrant je trouve avec les objets
<zmdkrbou> :)
<SKerjean> euh coq je veux essayer mais c vrai que pas evident
<zmdkrbou> strop le botrdel :)
<SKerjean> zmdkrbou j'aimerai bien verifier les preuves de bourbaki en coq :)
<zmdkrbou> enfin si tu mets pas les types t'es mort
<zmdkrbou> huhuhuhu
<dylan> LOL
<zmdkrbou> dylan: yes, coq sucks cocks :D
<dylan> My girlfriend is laughing over my shoulder as she translated this for me. ;)
<dylan> *translates
<zmdkrbou> lol
<SKerjean> i am despered to see an implementation of standard ZF in coq :)
<zmdkrbou> is she french ?
<zmdkrbou> lol
<dylan> No, native american and irish.
<dylan> She lived with a french family for a while, I believe.
<SKerjean> dylan but does she know coq (http://coq.inria.fr)?
<dylan> SKerjean: Well, after I explained that, yes.
<SKerjean> dylan is she a computer scientist ?
<dylan> Nope. But a programmer, or one in training. :)
<SKerjean> dylan and she uses coq ??
<dylan> I think if I forced her to learn ocaml or ICC she'd make me sleep on the couch. :)
<zmdkrbou> send an email to ..
<zmdkrbou> fuck
<zmdkrbou> i don't remember his name :)
<dylan> zmdkrbou: that's not a valid RFC822 email address.
<SKerjean> dylan eheh
SKerjean is now known as Anarchos
<zmdkrbou> dylan: alexandre miquel
* zmdkrbou thanls theblatte
<dylan> zmdkrbou: why?
* zmdkrbou 's too drunk
<zmdkrbou> dylan: about set theory
<zmdkrbou> he's the one
<zmdkrbou> he's the boss
<dylan> Okay. I will tell him I'm a rich nigerian widow interested in set theory.
<zmdkrbou> :)
<Anarchos> zmdkrbou je suis dans le salon #coq mais y a personne lol
<zmdkrbou> lol
<zmdkrbou> normal
<dylan> I'd be weird if there were people in there. and painful.
<dylan> *it'd!
<zmdkrbou> ??
* zmdkrbou 's weird
<dylan> I'll take your word for it.
<Anarchos> je quitte
<zmdkrbou> bn Anarchos
<dylan> Goodnight, Anarchos.
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
mikeX has quit [""zzz""]
zmdkrbou has quit ["#sos"]
skylan_ is now known as skylan
zigong has quit [Remote closed the connection]
Anarchos has joined #ocaml
<Anarchos> what is the status of the libcamlrun.a library in ocaml 3.09.1 ??
<Anarchos> it oesn't link anymore with my programs
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
bohanlon has quit ["It is sleepy time for my computer."]
__DL__ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
Banana has quit [Read error: 110 (Connection timed out)]
skylan_ has joined #ocaml
skylan has quit [Read error: 110 (Connection timed out)]
Skal has joined #ocaml
Banana has joined #ocaml
mattam has joined #ocaml
sirreality has quit ["Leaving"]
ppsmimou has joined #ocaml
nguenot has joined #ocaml
nguenot has quit [Client Quit]
zmdkrbou has joined #ocaml
pango_ has quit ["Client exiting"]
pango has joined #ocaml
Smerdyakov has quit ["Leaving"]
zigong has joined #ocaml
zigong has quit ["using sirc version 2.211+KSIRC/1.3.12"]
Anarchos has joined #ocaml
dozer has joined #ocaml
<dozer> afternoon
<dylan> 'ello, dozer.
<dozer> hi dylan
<dylan> How goes your adventure?
<dozer> fixed my problems from last night - it was a difference between imperative and declarative thinking I think
<dozer> thinkig about how to represent tagged data tructures in a jvm, without extremely sucky performance
<dylan> do you know how they're implemented in C?
<dozer> no
<dozer> but in c, you don't have the same memory-allocation restrictions as jvm
<dylan> this is true, but IIRC it's very simple.
<dylan> simple variants like this:
<dozer> presumably as the pair (tag,tuple)?
<dylan> type foo = Foo | Bar | Baz
<dylan> type foo is just represented by an int, I believe.
<pango> actually, constructors of 0-arity have a single instance in memory
<dylan> ja.
<pango> so they're represented by the reference to that single instance
<dozer> pango: so the instance pointer is the identity?
<pango> for 0-arity constructors only, yes
<dozer> type foo = Foo x | ... presumably can be represented as (ref(singleton(Foo)), x ref)
<pango> Foo is not 0-arity in your example
<dozer> no
<pango> for other arities, there's no such guarantee; from what I understand, ocaml would build a "custom memory block" with Foo tag in header, and one cell to store x (or a reference to x, if x is not scalar)
<pango> (or rather, boxed)
<dozer> understood
bohanlon has joined #ocaml
<dozer> are ocaml strings indexed from 0 to length-1?
<Anarchos> dozer yes
<dozer> and to convert a string to upper-case?
<dozer> can't see it in Pervasives or Str
<pango> Str is some kind of regexp library
<pango> try String
<dozer> ah thx
bohanlon has quit ["It is sleepy time for my computer."]
<telemakh0s> by 0-arity you mean something like "type t = Foo of int"?
<pango> that's 1-arity
<pango> 0-arity of type t = Foo
<dozer> I think they mean options that don't ahve an "of *" clause
<telemakh0s> ahh
<pango> right
<telemakh0s> I see
<telemakh0s> I though they meant invariants with 1 option...
<pango> don't know if there's an official name for those
<telemakh0s> am I just silly to use things like that?
ppsmimou has quit ["Leaving"]
<dozer> re-read the java6 vm stuff and apparently it will do on-the-stack allocation where it can prove that it's safe and then possibly decompose the object into its fields
<dozer> so perhaps it would work to implement tagged types in java as full classes and let the vm do the optimization at run-time
<pango> telemakh0s: could be useful to differenciate types, like dozer wanted a few days ago
<pango> telemakh0s: type car_id = CarName of string and person_id = PeopleName of string
<telemakh0s> pango: that's what I was thinking, I just didn't know if the convenience was worth any potential perfomance loss
<telemakh0s> pango yes, that's the kind of thing I'm doing
<telemakh0s> (it's actuall "type position = Position of int"
<telemakh0s> )
<pango> there's an extra dereferencing at pattern maching time, to access the string part
<dozer> presumably, this case of a single option with an explicit name can be safely optimized away after type-checking?
<pango> whether it's worth it depends on context ;)
<dozer> unless Ocaml allows run-time reflection...
<telemakh0s> pango hmm... a pointer derefence is just a single cpu instruction, right?
<pango> don't know if the compiler does such things
<dozer> telemakh0s: yes, but that de-reference could point to god-knows-where and force a cache flush
<telemakh0s> dozer, ahh, true...
<telemakh0s> dozer, ick
<telemakh0s> well... this will be done a couple of times per cycle of my inner-most loop... so maybe I'll just use ints and comments :P
<dozer> na - better to have it readable unless you notice that things are taking /too/ long
<dozer> remember, the source is for your benefit, not the computers
bohanlon has joined #ocaml
<pango> since incremental old generation Gc moves blocks around, the pointed block will be moved next to its reference after a while
<telemakh0s> dozer, this isn't one of those cases where "fast-enough" is a relevant term... I'm doing AI stuff, so faster is always better...
<dozer> pango: interesting
<dozer> oh? what ai./
<telemakh0s> dozer, distributed genetic programs for playing Go
<dozer> very nice
<dozer> I'm learing Go - got a board for xmas
<telemakh0s> I'm aiming for a Seti@Home approach to evolve Go playing programs
* telemakh0s is obsessed with Go...
<telemakh0s> most geeks' girlfriends have to pull them away from WoW or EVE Online... mine has to pull me away from PandaNet (Online Go network)
<telemakh0s> well... now that we're on the topic (not that I'm by any means at that point inmy design)... Anyone know of an easy way to get Ocaml to draw to the root window and work with xscreensaver?
bohanlon has quit ["It is sleepy time for my computer."]
bohanlon has joined #ocaml
<pango> telemakh0s: question was asked in the mailing list in May 2004, but no very useful answers
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
bohanlon has quit [Client Quit]
<telemakh0s> is it more common in FP to stub out some high-level functions at the outset of a program, or to break up your data into types first? I would imagine that the type base approach is more of an OO practice...
* ski often writes types first
<ski> (at least core types)
<telemakh0s> so do I, but I find myself writing types, and then while writing function realizing that my types aren't well formulated, so I didn't know if it would be better to take the function approach, and just write the types as I need them...
<ski> depends on what kind of function it is, i guess
<telemakh0s> I suppose
<ski> if it pattern-matches i usually write the type first
<ski> (but often refining the type and the function in parallel)
<telemakh0s> I see
zigong has joined #ocaml
Smerdyakov has joined #ocaml
<telemakh0s> I was just reading up on the differences in approach between FP and OOP on the WikiWikiWeb the other day, and they were talking about how OO gets caught up in noun syndrome and the relationships between objects get obfuscated because people are trying to manifest every aspect of the program as a noun...
<ski> mhm
<telemakh0s> so I guess I was just wondering if maybe that same problem could be manifest if you spent too much time defining a bunch of types instead of just writing functions and adapting your type base on a need-only basis...
<telemakh0s> </ramble>
bohanlon has joined #ocaml
<ski> defining types is essential for many things
<ski> but, it's usually not so complex
<ski> classes doesn't really compare well with types
<telemakh0s> of course... I'm mostly just thinking with my fingers about how I always seem to get caught up in trying to perfect my type base before even writing any functions...
bohanlon has quit ["It is sleepy time for my computer."]
Demitar has quit ["Bubbles..."]
bohanlon has joined #ocaml
Skal has quit [Remote closed the connection]
<telemakh0s> :w
<telemakh0s> er... wrong window :P
<zmdkrbou> vim rulez
<telemakh0s> indeed
<telemakh0s> I was wondering if anyone would recognize that :P
smimou has joined #ocaml
bohanlon has quit ["It is sleepy time for my computer."]
<dozer> yay - ~100 lines today and it compiled 3rd time
<telemakh0s> I can't even change a single line with out at least a warning :(
<ski> hm ?
pango_ has joined #ocaml
pango has quit ["Leaving"]
Anarchiste has joined #ocaml
Anarchiste has quit [Read error: 104 (Connection reset by peer)]
Anarchos has joined #ocaml
<Anarchos> how can i link some C programs against libcamlrun.a ?
<Anarchos> it hasn't been working since i upgraded from ocaml 3.08 to 3.09
<flux__> did you see the hint related to #define?
<flux__> some symbol names may have changed
<Anarchos> flux__ i changed them but it still say undefined reference on the new names
<flux__> anarchos, have you tried running nm on the libcamlrun.a and your objects?
<Anarchos> flux__ yes : in libcamlrun.a i find caml_copy_int32
<dozer> just had some extreme weirdness
<Anarchos> in my prog : caml_copy_int32_Fl
<Anarchos> it sounds like i should not compile with g++ or change something to demangle the names ...
<flux__> hmh, you aren't programming in c++ per chance?
<dozer> "f a b c Atype(x,y)" gave "This function is applied to too many arguments, maybe you forgot a `;'"
<flux__> (is that the correct way to use expression "per chance"?-))
<dozer> "f a b c (Atype(x,y))" was fine
<dozer> (flux__: yes)
<flux__> dozer, well, the first one is parsed like f a b c (Atype) (x, y)
<dozer> another day, another thing learned
<flux__> dozer, btw, some have defined operator let ($) a b = a b
<flux__> dozer, so you can write f a b c $ Atype(x, y)
<flux__> except that $ is a bad choice, because it somehow interferes with camlp4o
<flux__> I think I've used @@ for that
<dozer> ok
<dozer> so when do you put the name after let in brackets?
<dozer> if it'sa symbol?
<flux__> hmm.. what do you mean?
<dozer> whell, why let ($) ... rather than let $ ...
<Anarchos> flux__ i use some extern "C" in my headers, jsut forgot them !
<Anarchos> flux__ now i remember thanks a lot
<flux__> anarchos, happy to help ;)
<flux__> such problems can really be annoying, you can look at the code for hours and not figure out the simplest thing..
<flux__> dozer, oh, you need parenthesis when you are defining operators
<flux__> dozer, when you want to refer to an operator as a function, you use parenthesis around it
<flux__> like: (+) 1 2
<dozer> ok ... in what way does an operator behave differently to an operator?
<dozer> in the case of (+), it's infix
<Anarchos> Is it possible to submit some ideas to the caml team if some member is here ?
<flux__> anarchos, the biggest difference between operators is their precedence
<flux__> s/anarchos/dozer/
<flux__> and the precedency is determined by the first character of the operator
<flux__> anarchos, I don't think there are any caml team members around here..
<Anarchos> ok no problem
<flux__> dozer, similarly arity also comes from the first character, let (!+) a = a + 42 defines an unary function
<Anarchos> flux__ lol i am lucky to know the s command in sed ;)
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
<dozer> flux_ is there a cheat-sheet with all of this in?
<srle> hi
<srle> what kind of optimizations ocaml compiler can do when function is not recursive?
<Smerdyakov> srle, the OCaml compiler avoids optimizations in general.
<flux__> dozer, the ocaml documentation?-)
<dozer> right - my program runs, it's friday and there's still beer in pubs
<dozer> see you next week
<srle> Smerdyakov : can you explain a little?
dozer has quit ["Kopete 0.9.2 : http://kopete.kde.org"]
<Smerdyakov> srle, we generally take "optimizations" to be transformations that involve some analysis of code and decisions about transformations to make.
<Smerdyakov> srle, the OCaml compiler does hardly any optimization, under that definition.
<srle> Smerdyakov : then, why do i have to type "let rec" of "let"?
<Smerdyakov> srle, that's a language semantics issue....
<Smerdyakov> srle, you can be pretty sure that a "let rec" without any actual recursive definition is compiled the same way as the "let" version.
<srle> Smerdyakov : I thought that it had some things wiht optimizations.
<Smerdyakov> srle, I doubt it.
<pango_> it's just a matter of definition scope, I think
<srle> Smerdyakov : When someone assumes that function is recursive then compiler has to put local variables to stack. I thought that if function is not recursive that that is not always nececary.
<Smerdyakov> srle, I don't think you're right.
<srle> Smerdyakov : I was wrong?
<srle> Smerdyakov : I know what you are thinking. I said 'not always'. I was thinking that there was a reason for puthing 'rec' there.
<pango_> let f n = n ;; let f n = f n + 1 works
<pango_> if you add "rec" after the second let it goes in an infinite loop (or rather runs in a stack overflow)
<pango_> so using or not using rec depends on what you wanted
<srle> pango_ : was that only reason?
<srle> pango_ : I have read ti on internet that people complaing about that 'feature'.
<pango_> I'm not inside the compiler, but I'd say "rec" keyword has absolutely nothing to do with optimization
<pango_> what are they complaining about ?
<srle> pango_ : something like this. Is ocaml compiler so stupid that it can not conclude that function is recursive. Something like that.
<Smerdyakov> srle, this isn't an optimization rule.
<Smerdyakov> srle, it matters for the MEANING of your program.
<srle> pango_ : or, I dont want to do compilers job.
<Smerdyakov> srle, consider the difference:
<Smerdyakov> let f x = f x
<Smerdyakov> let rec f x = f x
<Smerdyakov> The first one may be total, while the second is a non-terminating function.
<pango_> srle: you're free to overload definitions, so the compiler cannot guess
<srle> pango_ : what was the idea with 'rec' in the first place?
<pango_> try let f n = n + 3 ;; let f n = 2 * n ;; and see how the compiler doesn't complain
<pango_> rec makes the current function visible from within its own definition
<srle> pango_ : thanks for the info.
<srle> Smerdyakov : tnx.
<pango_> btw the possibility to overload function definitions may be sometimes useful, but it can become confusing too
<Smerdyakov> pango_, I think the right term is "shadow," not "overload."
<pango_> let's go for shadow
<telemakh0s> which is faster, a (int, int) Hasktbl, or and int array array for random read access??
<pango_> anyway, it can be used in artistic ways to make code almost unreadable
<telemakh0s> was that a bed question, or does noone know?
kral has joined #ocaml
<pango_> telemakh0s: I suppose the default hashing function used in Hashtbl makes the array array solution faster, if everything fits in memory
<telemakh0s> what about assoc list? (I just thought of that)
<pango_> linear time
<telemakh0s> as opposed to constant time, in array array?
* telemakh0s is assuming...
<pango_> assoc lists are just ('a, 'b) list
<telemakh0s> ahh
<telemakh0s> so the list has to be traversed for every search...
<telemakh0s> background: I'm trying to find the best way to represent a go board... 19x19, 361 points
<telemakh0s> there's a gnugo approach, and just have a char[361] array, and use (y * 19) + x to find an x,y position in the array, but I'm not sure if that would be faster then a double array lookup...
<pango_> probably will
<telemakh0s> that flat array would be faster?
<pango_> it also probably saves memory and number of allocations
<telemakh0s> yeah... wasn't thinking about that
<pango_> anyway, I think arrays are the way to go... Lots of algorithms will probably have some spatial locality
<telemakh0s> what do you mean be that?
<pango_> it's easier to find neighboor cells in an array
<telemakh0s> right... that's why I was thinking a double array might be faster, becase you don't have to do as much arithmetic to find cells above or bellow
<telemakh0s> the only thing that really needs to be fast is random read access
<telemakh0s> maybe I'll just try it a couple of ways and profile
<pango_> one problem with arrays is that they're modified in place, which makes backtracking more complex
<telemakh0s> backtracking? you mean, keeping track of what you do with it?
<telemakh0s> (the only way to index a double array is my_array.(x).(y), right?)
<pango_> revert all changes made since some decision, before trying another
<telemakh0s> I don't see why I would need to do that...
<telemakh0s> I see what you're saying, but I think you misunderstand what I'm trying to accomplish
<telemakh0s> the board that I'm storing explicitly in my program is going to be read only... the evolving algorithms that are going to be playing the game are going to have to manage thier own decision tree, so I'm not worried about how they are going to work through solutions....
<telemakh0s> the board I'm designing right now is just a reference for the _current_ state for the game... so anything being modified on this board is an actual move, and there is no undo
<pango_> yet exploring a decision tree often involves simulating moves
<pango_> if not always
<telemakh0s> right... and that's going to be managed by the randomly generated/mutated algorithms in thier own memory space... I don't care how they keep track of that...
<pango_> well, with mutable datastructures, you need to be careful about sharing
<telemakh0s> which is why it's read only... in the language that these agents are going to be coded in, there is no instruction for "write move to board"...
<telemakh0s> there is a "make move at this position" instruction, but it terminates the agent, plays the move, and starts running the opponent...
<pango_> but between the different board "states" within an agent ?
<telemakh0s> an agent is a state-machine... it only knows about the current board position, and exits as soon as it determines a move to make... it is started again from the beginning with clean memory on its next turn
<pango_> ok
<pango_> so that's how you handle backtracking
<telemakh0s> the only thing diferent is that an extra stone is on the board... or, rather, on element of the board array is changed
<telemakh0s> well, two, because there's the stone it played on it's last turn, and the stone the opponent played
<telemakh0s> I suppose... I don't really handle it... the agents have to manage all thier own stuff in thier scratch array
<pango_> then you're careful about sharing
<telemakh0s> the state of the Go board + a ko location creates a descrete state for each move...
<telemakh0s> of course, which is why there is only one instruction that can modify the real board, and that instruction is a move indicator and can only be executed once per execution of the agent
<telemakh0s> so all I need is a simple an fast representation of 361 values, each with three posibilities (empty, white or black) (ko information can be stored seperately)...
<telemakh0s> the only reason I don't want to go with a flat array is because it's hard for me to compute captures that way :P
<pango_> with 2 dimensions arrays, you can save some copying in each agent, by sharing vectors with the initial board
<pango_> and just copying and replacing the vectors where changes are made
<telemakh0s> that's true...
* telemakh0s contemplates
<telemakh0s> is there a native char module?
<telemakh0s> would it be worth using, or are you usually better of sticking with the word size of the machine you're on?
<telemakh0s> (int = word, right?)
<pango_> chars take 8 bits within strings
<pango_> otherwise, they usually take a whole word
<telemakh0s> ocaml doesn't pack chars?
<pango_> there's Bigarray s too
<telemakh0s> er... I guess unpacking takes CPU
<pango_> telemakh0s: Gc adds restrictions on how memory can be used too
Skal has joined #ocaml
<pango_> btw, if you don't mind memory usage, you may better use a sum type...
<pango_> type point_content = Empty | Black | White
<pango_> it will use one word, too
<telemakh0s> pango_, no meta-data?
<pango_> in that case, it will use a single word
<telemakh0s> I see
<telemakh0s> that's still only 361 * 8 bits
<telemakh0s> er, bytes
<telemakh0s> not bad, I might do that
<pango_> word = 32 bits on 32 bits archs, and 64 bits on 64 bits archs
<pango_> only chars will allow you to use only 8 bits (or Bigarrays with int8_(un)signed_elt
__DL__ has quit [Remote closed the connection]
mikeX has joined #ocaml
rillig has joined #ocaml
<rillig> Can someone explain to me this weird behavior? I have written http://www.roland-illig.de/tmp/charset.ml and hunted a syntax error for about half an hour. Then, I inserted a begin...end around lines 48 and 49, and now it works.
kral has quit [""In girum imus nocte et consumimur igni.""]
<rillig> But I don't understand why this begin..end is necessary.
<mikeX> rillig: if else should have the same return type
<mikeX> rillig: actually, your if statement is wrong
<rillig> what should I have written?
<mikeX> judging from your identation, that's not what you really want
gim has joined #ocaml
<mikeX> the 'else' clause should be attributed to some of the above ifs I guess
<mikeX> rillig: if you want to group two or more statements you *have* to enclose them in 'begin .. end' or ( .. ) (the same thing)
<rillig> hmm, I see. The str.ml from the O'Caml distribution does the same. How could I have ever overlooked that?
<rillig> thanks.
<mikeX> np
<rillig> hmm, but then I would have expected a syntax error, because there is a stray "else".
<mikeX> you also *have* to use begin..end/(..) to avoid a dangling else
<mikeX> that's the poing, it's not stray, it's matched with one of the above if statements
<mikeX> point
<rillig> ok.
<mikeX> for example: if true then printf "hello" as if you have written 'if true then printf "hello" else ()'
<mikeX> so if you skip that else, but leave a stray else somewhere later on, the compiler matches that to the one you ommited
<mikeX> (assuming it's return type is also unit)
<rillig> another thing I haven't understood is when to use ;; and when not to use it.
<mikeX> rillig: i never use it
<mikeX> it's used primarily in the interactive toplevel
<rillig> ok, so it's just for the top-level interpreter
<mikeX> from what I understand
<rillig> fine.
Revision17 has joined #ocaml
<mikeX> is this what you had in mind?
<rillig> yes.
<mikeX> with you ommitin the ( ) in the last if, you had this:
<rillig> so the scope of "let" extends to a group of statements, but the "if" does not.
<mikeX> if i1 < len && s.[i1] = '-' then let (i2, c2) = parse_char (i1 + 1) in cs#add_range c1 c2 else ()
<mikeX> hmm, still I'm not making my point, anyway .. maybe you get the idea now
<rillig> yes, I got it.
<rillig> so it's almost like in C: if you don't want unexpected behavior, write parentheses and braces around everything.
<mikeX> hmm, at least in the if .. else case
<mikeX> hmm, not so sure, but I think this is what ocaml thought you meant:
<mikeX> not even close right?
<rillig> I just read the reference manual, which states: expr ::= [expr {; expr} ].
<rillig> in another place, it is said that the parser always looks for the longest matching text.
<mikeX> rillig: isn't that the expr for lists?
<rillig> oops. yes, the [ might be meant to be a literal "[".
<mikeX> yes, judging from the [| |] just after it
<mikeX> |
<mikeX> expr ; expr
<mikeX> that's the one you want, in addition to if expr then expr [ else expr ]
<mikeX> (where in this case, it's not a literal [)
<mikeX> The expressions ( expr ) and begin expr end have the same value as expr. Both constructs are semantically equivalent, but it is good style to use begin ... end inside control structures:
<mikeX> if ... then begin ... ; ... end else begin ... ; ... end
<rillig> ... and the precedence of ";" is lower than that of the "if".
<rillig> page 109 at the bottom.
<mikeX> indeed
pengo has joined #ocaml
twobitsprit1 has left #ocaml []
JosephRivers has joined #ocaml
<JosephRivers> Hey, is there any way to create functions in ocaml that will be evaulated at compile time instead of run time?
<mikeX> JosephRivers: an example being?
<JosephRivers> mikeX: Consider a factorial function. Suppose you wanted to write a function like f x = x * factorial 20, but you didn't want factorial 20 to be evaluated each time the function was called.
<JosephRivers> mikeX: http://en.wikipedia.org/wiki/Template_metaprogramming here's how you can do it using C++ templates
<pengo> JosephRivers: i dont know ocaml, but what you want is often called a macro.
<mikeX> interesting
<mikeX> hmm, not exactly pengo
<JosephRivers> pengo: not necessarily. Macros allow for rewriting and code generation, but they usually don't allow for compile time computation. For example the template metaprogramming example I linked to probably couldn't be done with C's preprocessor
<mikeX> in his case, the factorial function is something declared previously in the program
<pango_> let f20 = factorial 20 ... let f x = x * f20
<mikeX> I think this falls into the category of compiler optimization
<pango_> being at toplevel, f20 will be computed at module evaluation
<pango_> hence once when the program starts
<mikeX> still that's not compile time
<pango_> ok compile time
<pango_> let f20 = 1 * 2 * ... * 30 :)
<mikeX> hehe :)
<pango_> that will be evaluated at compile time
<JosephRivers> Could it possibly be done with the camlp4 preprocessor?
<pango_> check MetaOCaml
<mikeX> ooh, metaocaml seems interesting :)
<pengo> i actually assumed ocaml would do a lot of compile time optimisation, seeing it's so well defined which functions are can be used at compile time.
<JosephRivers> but it would still be nice to have a way to guarantee that it would be computed at compile time
<mikeX> pango_: is this like reflective programming?
<pango_> no idea, I left uni a long time ago
<pango_> you could as well talk chinese
<mikeX> ching hua
<mikeX> ;)
<pango_> what about functions that don't terminate ? is it better if they're evaluated at compile time ? :)
<mikeX> what did you study pango_ ? computer science?
<pango_> software engineering, so they say
<mikeX> haha
<pango_> I'm not sure it's the same thing... Reflection seems to be the ability to influence or observe the program at runtime
<pango_> MetaOCaml seems to be about automated program generation
<mikeX> mm yes
<pango_> so interesting work is done before the program is even started
<pango_> as is it, ocaml has almost no support for reflection
<mikeX> so many interesting stuff out there :)
<pango_> functions are abstract values, almost all types are thrown away after compilation (See what Obj can tell you about datastructures at runtime... it's very limited)
gim has quit ["dead-tired"]
<mikeX> i see
<pango_> ocaml seems aimed at very high runtime safety, not being able to do fancy things at runtime
<pengo> surely you could write a reflective OCaml in OCaml without too much difficulty? :)
<mikeX> :o
<pengo> <-- naive coder
<mikeX> hahahah
<pango_> well, maybe it's because I haven't used reflexion effectively, but I wonder what can be learnt at runtime from an ocaml program that couldn't be determined at compile time
<pengo> pango_: reflection is useful for debugging/debuggers, and for examining objects received over a network at runtime
<pango_> the Wikipedia page says such things exist, but at 0h40 I fail to see what it would look like
<pengo> i'm sure it's useful for something else but i can't think of anything
<pango_> actually receiving random things from the network is a challenge for ocaml
<pango_> unmarshalling isn't currently safe
<pengo> i use reflection in java to subvert its type system
<pango_> they're experimental works being done in that direction
<pango_> pengo: let's not talk about that, the moon is almost full already
<mikeX> lol
<pengo> is java a four letter word here?
<pango_> well, for me it is
* zmdkrbou slaps java
<pengo> :)
<pango_> don't know about others
<mikeX> j#@*
<pengo> i'll take that as a yes
<pango_> yes, adding metadata to data can be useful in debuggers, and exchanges with other programs
<pango_> but it seems to be seen as special cases in ocaml, rather than a basic, pervasive mecanism
<mikeX> hmm, if i mix lgpl with gpl source, what do i get?
zigong has quit ["using sirc version 2.211+KSIRC/1.3.12"]
<pengo> mikeX: depends how you mix it.. lgpl library + gpl source is fine
<mikeX> actually, I've taken the ocaml-3.09.1/byterun/md5.c and crc32.c (from cksfv, gpl) and put them together in one file
<mikeX> making a few changes in the process
<mikeX> (md5.c is L-GPL from what I understand)