<Tomsik>
and the error I get is Error: The record field label stick belongs to the type lpoint
<Tomsik>
but is mixed here with labels of type ldirectional
<Tomsik>
at line | LDirectional {stick = true} -> h
<Camarade_Tux>
Tomsik: you can't use the same name in different record types, it messes up type inference
<mrvn>
record labels shadow other record labels
<Tomsik>
Ah darn
<Tomsik>
That's kinda sad
<Tomsik>
What's the way around this, besides changing label names?
<Camarade_Tux>
you can prefix the names or define the records in modules (or use objects but I wouldn't recommend it if your only motivation is names)
<mrvn>
In this case I would define a type kind = Directional | Point and type light = { kind : kind; position: Vector.t; diffuse: Vector.t; ambient: Vector.t; specular: Vector.t; shiny: float; shadows: bool; stick: bool}
<Tomsik>
Sounds reasonable
<Camarade_Tux>
considering the types, mrvn's approach is much better (sorry, hadn't really looked at the code)
<mrvn>
Or type kind = Ambient | Point of Vector.t | Global of vector.t | Directed of Vector.t * Vector.t
<mrvn>
Tomsik: I would further suggest defining different types for position and color vectors.
<quelqun_dautre>
&w 18
<Tomsik>
hmm, right now I want that to compile
alexyk has joined #ocaml
Oxyd has joined #ocaml
ulfdoz has quit [Read error: 110 (Connection timed out)]
<thelema>
caml-list now notified of batteries 1.0.0
<thelema>
(poorly)
<Camarade_Tux>
nice :-)
<Camarade_Tux>
[1] Like the small batteries used in TV remote controls <- there's no [1] in the mail body ;-)
<thelema>
as I said, poorly.
<Camarade_Tux>
thelema: how big is a battery hello world now?
<thelema>
ah, I dropped the AAA bit. Wow, that'll make zero sense.
<thelema>
executable?
<Camarade_Tux>
yeah, you mentionned smaller executable; I was aware of that but I don't have any figure
<thelema>
gimme a sec to compile
yakischloba has joined #ocaml
<mfp>
Camarade_Tux: depends on which modules you use; if you have open Batteries, it's 3.2Mb here
<mfp>
with let () = BatPrintf.printf "Hello, world\n", it's down to 750 KB
<mfp>
and some 9 KB IIRC if you use dynamic linking (ld_ocaml)
<thelema>
750KB for [ open BatInnerIO let _ = nwrite stdout "Hello World\n" ]
<thelema>
BatIO is much larger than batInnerIO. I have the bad feeling batteries 2.0 will be coming out soon where all the write_* functions in BatIO are removed
<Camarade_Tux>
ok, thanks both
<Camarade_Tux>
I don't use "open" a lot so I guess it'll be 750KB for me :-)
<thelema>
you do have to give up some convenience to get the smaller executable sizes. The [open Batteries] pulls in a ton of stuff into your namespace, but it all gets compiled in.
<thelema>
It depends on what you use - once you use BatPervasives, I think that uses BatIO which uses a ton of modules... for no good reason I can see.
<Camarade_Tux>
I know, currently I prefer not to use open too much so it doesn't pull to many things in the current namespace and the reduced convenience is usually ok (I "rename" modules, or I only open submodules)
<thelema>
Camarade_Tux: ok.
<mfp>
open BatPervasives let () = BatPrint.printf p"Hello, %rope\n" r"world" -> 2.2 MB
<Camarade_Tux>
and I'm probably going to try to use ld-ocaml now ;-)
<Camarade_Tux>
only need to make ocamlbuild output .cmxs files and use packs
ccasin has joined #ocaml
<thelema>
mfp: it's almost the same if you open BatIO instead of BatInnerIO
my007ms has left #ocaml []
<thelema>
mfp: btw, I renamed the github repo - instead of "AAA-batteries" it's "batteries-included"
<thelema>
You'll have to change your .git/config to match
<mfp>
yeah, just noticed and changed the git remote
<thelema>
ok.
yakischloba has quit ["Leaving."]
smimou has joined #ocaml
<mfp>
hmm just installed and ocamlfind list shows batteries 0.9.2, forgot to update the version in the META?
<thelema>
No, that should be ... hmm, mine shows 0.9.2
<mfp>
yup, VERSION = 0.9.2 in OMakefile
<thelema>
The version in the META should be auto-generated from the META.in
<thelema>
Hmm, I changed that.... except...
<thelema>
what's your source
<mfp>
I just fetched & merged, it's 0.9.2 in your (thelema/batteries-included) tree
<Camarade_Tux>
that's really nice, for my browser project, I have several dependencies and different executables with some dependencies in common which make the whole about twice as big as it could be if modules were shared and it's starting to get quite frustrating ;p
<thelema>
mfp: very nice.
<mfp>
actually 8608 bytes after strip -s
<thelema>
debugging and profiling still work?
ccasin has quit ["Leaving"]
<mfp>
ld_ocaml is for native code only, so debugging isn't affected
<mfp>
as for profiling, I haven't tried it. You'd probably need a separate DLL catalog for the profiling-enabled libs.
<mrvn>
only if you want samples from inside the lib
<mfp>
you are not going to distribute binaries with profiling enabled anyway, so the exec size doesn't matter
<thelema>
fair enough.
<mrvn>
Let me know if it is good
<mrvn>
ups
Modius has joined #ocaml
_zack has quit [Read error: 54 (Connection reset by peer)]
_zack has joined #ocaml
ttamttam has joined #ocaml
Narrenschiff has quit []
Submarine has joined #ocaml
ulfdoz has joined #ocaml
ttamttam has quit ["Leaving."]
_JFT_ has quit []
tmaedaZ0 is now known as tmaedaZ
tmaedaZ is now known as tmaedaZ0
_zack has quit ["Leaving."]
avsm has joined #ocaml
hyperboreean has quit ["leaving"]
djanderson has joined #ocaml
joewilliams has joined #ocaml
alexyk has quit []
hyperboreean has joined #ocaml
boscop has joined #ocaml
<boscop>
would you recommend ocaml for game development?
<mrvn>
boscop: why shouldn't one?
<boscop>
I heard ocaml has slow floats?
_unK has quit [Remote closed the connection]
<mrvn>
so don't write quake in it
<boscop>
mrvn, and there don't seem to be many game related libraries available
<mrvn>
like what?
<boscop>
like only chipmunk for physics, no box2d etc
Yoric has quit []
<boscop>
I don't know how it is for networking...
<mrvn>
write some bindings then.
<Tomsik>
I'm not sure if functional languages are good for games
<Tomsik>
I mean, games are based mostly on input
<Tomsik>
and it's imperative in its nature
<Tomsik>
ocaml has imperative part, but isn't it mainly a functional language?
<mrvn>
it has quite a good mixture
<Tomsik>
I'm not sure, but I guess it would be interesting to try to write a game in it.
<Tomsik>
brb
<mrvn>
Board games work well in ocaml I think. And you can use objects for imperative things rather well usualy.
<boscop>
the reason I thing about it is, I'm very frustrated with C++, but I need it's speed for my current project
<mrvn>
what is it?
<boscop>
a fast-paced 2d action shooter with physics and multiplayer
ikaros has quit ["Leave the magic to Houdini"]
Oxyd_ has joined #ocaml
<Tomsik>
AFAIK ocaml is quite fast
<mrvn>
except that floats are rather slow because they are always boxed.
<mrvn>
better to use 31 bit fixed point math
<Tomsik>
I wonder when there'll be CUDA for ocaml :p
<boscop>
but libraries probably don't use fixed point
<boscop>
if there are any :/
Oxyd has quit [farmer.freenode.net irc.freenode.net]
diml has quit [farmer.freenode.net irc.freenode.net]
brendan has quit [farmer.freenode.net irc.freenode.net]
infoe_ has quit [farmer.freenode.net irc.freenode.net]
BigJ has quit [farmer.freenode.net irc.freenode.net]
<boscop>
would it be easy to write box2d bindings?
<mrvn>
Tomsik: write bindings
<mrvn>
boscop: if you know the lib you can usualy write some bindings over the weekend.
avsm1 has joined #ocaml
<boscop>
will it be as fast as native C++?
avsm has quit [Read error: 104 (Connection reset by peer)]
<mrvn>
Depends on what you do
<mrvn>
c++ can be quite slow too
<boscop>
I mean will the box2d code be as fast as the C++ version with those bindings?
<mrvn>
calling a C function does cost some time. There is some overhead for the GC and such.
onigiri has joined #ocaml
brendan has joined #ocaml
BigJ has joined #ocaml
infoe_ has joined #ocaml
diml has joined #ocaml
<Tomsik>
boscop: don't worry, either way it won't be as slow as java or python :p
<boscop>
what about c#?
<Tomsik>
no idea
<mrvn>
boscop: sucks
<boscop>
mrvn, I have the same feeling
diml has quit [farmer.freenode.net irc.freenode.net]
brendan has quit [farmer.freenode.net irc.freenode.net]
infoe_ has quit [farmer.freenode.net irc.freenode.net]
BigJ has quit [farmer.freenode.net irc.freenode.net]
brendan_ has joined #ocaml
infoe_ has joined #ocaml
<mrvn>
They have a horrible GC that I would think would ruin your game.
BigJ has joined #ocaml
brendan_ is now known as Guest55111
diml has joined #ocaml
<boscop>
mark-and-sweep?
<mrvn>
stop-and-go
<mrvn>
stop-the-world GC
<boscop>
D has that, too
<boscop>
I first started my project in D
<boscop>
it's box2d port is slower than java's due to the GC
<mrvn>
I guess it largely depends on how you get the data from box2d back to ocaml or from ocaml to box2d
<boscop>
what about networking?
<boscop>
is there good support for it?
<mrvn>
a bunch of libs
joewilliams has quit [Remote closed the connection]
Tomsik_ has joined #ocaml
Submarine has quit [Read error: 113 (No route to host)]
Tomsik has quit [Read error: 60 (Operation timed out)]
_unK has joined #ocaml
onigiri has quit []
onigiri has joined #ocaml
alexyk has joined #ocaml
avsm1 has quit ["Leaving."]
<mrvn>
Will ocaml-dl allow multiple ocaml libraries to be loaded into a C binary?
mjsor has joined #ocaml
<mrvn>
bah, ocaml code is much nicer
<mrvn>
ups
<mrvn>
ECHAN
avsm has joined #ocaml
mjsor has quit []
Morphous is now known as Amorphous
M| has quit ["leaving"]
itewsh has joined #ocaml
M| has joined #ocaml
c0m has joined #ocaml
<c0m>
anyone around
<boscop>
nope
<c0m>
nice
<c0m>
NxN matrix with each individual row increasing left to right and each column increasing from top to bottom ....given an O(N) worst-case algorithm that decides if X is in matrix
<c0m>
so does that mean if N were 3 .. the matrix would be
<c0m>
1 2 3
<c0m>
2
<c0m>
sorry
<c0m>
1 2 3
<c0m>
2 3 4
<c0m>
3 4 5
<c0m>
?
<c0m>
someone proposed just going through the entire matrix using nested for loop
<c0m>
but that would be an O(n^2)
<c0m>
and they are saying it wouldn't be
<boscop>
increasing by 1 always?
<mrvn>
I'm assuming the values can skip some values.
<boscop>
is it sorted?
<boscop>
err, forget that
<mrvn>
But you will still have some roughly diagonal on which the value would be.
<boscop>
do binary search on the upper row
<c0m>
well my first question is
<mrvn>
So go to the right till you find a value to big, then one down and to the left till you find one to small again and so on
<c0m>
they are saying to do nexted for loop checking each one
<c0m>
but if you get to the end, that is as if n^2
ubuntu_ has joined #ocaml
<c0m>
and they are saying it is not
<Camarade_Tux>
aren't all the naturals between 1 and 2*N+1 included in such a matrix?
<mrvn>
1 5
<mrvn>
7 9
<Camarade_Tux>
oh wait, I can't read :-)
dark has quit [Remote closed the connection]
<Camarade_Tux>
I don't know why I had dreamt the numbers were always increasing by 1 ;-)
ubuntu_ is now known as dark
<mrvn>
That would be boring
<Camarade_Tux>
definitely :P
<boscop>
c0m, binary search gives you O(log(n))
<mrvn>
boscop: no, still O(n)
<boscop>
it's sorted
<mrvn>
but you can't binary search the diagonal
<boscop>
you can search the upper row
<boscop>
that's all you need
<mrvn>
boscop: Why should the value be in the upper row?
<boscop>
ah no, + the right column
<boscop>
so O(log(2n-1))
<mrvn>
boscop: why should the value be in the right column?
<boscop>
because of the definition of the matrix
<mrvn>
1 5
<mrvn>
7 9
<mrvn>
boscop: 7 is neitherin the top nor right column.
<boscop>
that's a wrong example
<c0m>
well that sounds correct
<boscop>
c0m, you have to specify more
<c0m>
increasing left to right and top to bottom
<c0m>
that's all the prob says
<boscop>
ah
<boscop>
then of course all
<mrvn>
c0m: increasing or strictly increasing?
<mrvn>
=> or >
<c0m>
The input is an NxN matrix of numbers that is already in memory. Each individual row is increasing from left to right. Each inidividual column is increasing from top to bottom. Give an O(N) worst-case algorithm that decides if a number X is in the matrix.
<c0m>
that's the exact problem
<mrvn>
as said, go right till its too big, then diagonal
<c0m>
yes
<c0m>
that looks about right
<Camarade_Tux>
(and don't forget to be cache friendly if you code it ;-) )
<mrvn>
Camarade_Tux: that doesn't play into the O() notation
<Camarade_Tux>
yeah, that's why I added "if you code it" ;-)
<boscop>
no
<mrvn>
c0m: Worst case you go N times right, N times down and N times left.
<boscop>
1 2 4
<boscop>
3 6 7
<boscop>
5 8 9
<boscop>
you search for 6
<mrvn>
so you search 1 2 4 7 6
<boscop>
that's more than N
<c0m>
how about this
<boscop>
ah, nvm
<mrvn>
But not more than O(N)
<c0m>
people are telling me that you go through every element
<c0m>
it is not n^2
<boscop>
yea yea
<c0m>
for O()
* c0m
sighs
<mrvn>
c0m: every element is certainly O(N^2)
<c0m>
yup
<c0m>
you should see their arguements
<mrvn>
Doing binary search in every row would be O(n log n)
<boscop>
c0m, where does this problem appear?
alexyk has quit []
<c0m>
textbook
<Tomsik_>
well, it's probably O(log^2 n)
<Tomsik_>
you can check ends of rows to check if the number might be there
<Tomsik_>
and then binary search inside
<mrvn>
Tomsik_: worst case it always might be
<Tomsik_>
worst case is that every number is the same
<Tomsik_>
and you have to write out whole matrix :p
<mrvn>
Tomsik_: no. still only O(N)
<Tomsik_>
gotta run, see ya
Tomsik_ has quit [Client Quit]
c0m has quit ["ChatZilla 0.9.86 [Firefox 3.5.7/20091221164558]"]
joewilliams has joined #ocaml
tty56 has joined #ocaml
ztfw has joined #ocaml
tty56 has quit []
djanderson has quit [Client Quit]
Submarine has joined #ocaml
demitar has joined #ocaml
avsm has quit ["Leaving."]
demitar has quit [Client Quit]
<boscop>
are there bindings for Qt or wxWidgets for OCaml?