<jlamar>
Then I try to do something like: GlDraw.vertex3, and it's an unbound value
<exarkun>
hmm, haven't worked with gl in ocaml.. I assume lablgl.cma provides GlDraw?
<jlamar>
I can only assume so, since the rest of the modules are cmx
<jlamar>
And when I try doing it with ocamlc, it works fine
<jlamar>
ocamlc -I +lablgl lablgl.cma <file> works
<exarkun>
maybe you need to make a custom interactive interpreter?
* exarkun
is just guessing.
<jlamar>
I tried making a custom toplevel using the same parameters
<jlamar>
No dice
<exarkun>
hrm
<jlamar>
My friend gets "Unbound value" even using ocamlc and ocamlopt, the examples for lablgl won't even work for him
derfy has joined #ocaml
<jlamar>
Ehh... I'll look at it later... thanks anyway
* jlamar
is away: lunch
derfy has quit []
TimFreeman has joined #ocaml
TimFreeman has left #ocaml []
<smkl>
jlamar: you need to run the toplevel with "-I +lablGL" or use #directory "+lablGL"
* jlamar
is back (gone 01:06:32)
<jlamar>
Hmm..let me try thatr
<jlamar>
that
<jlamar>
Hmmm, that works!
<jlamar>
But when I try to make a toplevel that has -I +lablgl, it doesn't work
<smkl>
the reason why it doesn't work otherwise is that #load just links, the code executed by the toplevel needs to be compiled, and it compiles it just the same way it would otherwise
<jlamar>
Oh... I see
<smkl>
with ocamlmktop, the -I +lablGL is just passed to the linker
<jlamar>
Is there a way to have it so it compiles the interface?
<smkl>
you can make a shell script that calls the toplevel with the include, like "lablgtk" and "lablgl" scripts
<jlamar>
Oh.. yes, that makes sense.. thank you
<jlamar>
Um... actually
<jlamar>
ocaml -I +lablgl doesn't seem to compile the interface
<jlamar>
And /usr/bin/lablgl doesn't seem to, either
<smkl>
??
<jlamar>
The functions are unbound when I run lablgl
<jlamar>
Only changing the directory seems to work
<jlamar>
That's odd
<smkl>
is this the latest version?
<jlamar>
Of what?
<jlamar>
I'm running ocaml 3.04 and lablgl 0.97
<jlamar>
Which aren't the latest of either
<smkl>
it should install to directory +lablGL
<jlamar>
Mine is lablgl
<jlamar>
I'm running Debian, if that helps any
<jlamar>
It's not a huge deal because it seems to work fine when I use ocamlc and ocamlopt
<smkl>
probably something is wrong with debian packages then
<jlamar>
Yeah, it's entirely possible, but shouldn't it work with an arbitrary directory?
TimFreeman has joined #ocaml
<TimFreeman>
Has anyone used ocamlmakefile to build a lablgtk program? When I do it, it's ugly, so there must be a better way.
<smkl>
TimFreeman: no, but why does it look ugly?
<Dybbuk>
Sometimes things are ugly.
<smkl>
jlamar: when you do ocaml -I +lablGL, can you #load "lablgl.cma";; ?
<jlamar>
smkl: Never mind, it works now
<jlamar>
smkl: Though I'm not sure why... lablgl doesn't work, but my custom toplevel script works
<TimFreeman>
To make a standalone executable, I need to pass "-thread unix.cma threads.cma lablgtk.cma gtkInit.cmo gtkThread.cmo" as extra arguments to ocamlc, I think. ocamlmakefile doesn't seem to support putting the extra .cmo's ...
<TimFreeman>
there, so I have to put the entire incantation on OCAMLBLDFLAGS.
<TimFreeman>
That's ugly because everything but the .cmo's is already there via reasonable channels, so it's redundant to have it there again. But I need it again so they are introduced in the right order. Actually, although I don't get ...
<TimFreeman>
build errors, the program segfaults when it runs so there might be something else wrong.
<TimFreeman>
Actually, the redundancy was causing the segfault. When I create a redundancy-free build command by hand, no segfault. So it's worse than ugly.
<smkl>
perhaps just make your own gtkinit.cma from those two files?
<TimFreeman>
That's a good idea. I'll try it.
<TimFreeman>
I built a library, but I don't know if I grabbed all of lablgtk or just the files I needed. How do I list the contents of a .cma?
<TimFreeman>
Never mind, I just found the original .cmo's so I don't need to derive one .cma from another.
<smkl>
here is how to write existential types using the new polymorphism:
<smkl>
module EX (T:sig type 'a p end) = struct type 'b f = { f : 'a. 'a T.p -> 'b } type t = { ex_c : 'b. 'b f -> 'b } let elem x = { ex_c = (fun f -> f.f x) } let elim g {ex_c=f} = f g end
<smkl>
or at least the best way i could think of
<TimFreeman>
What are elem and elim supposed to do?
<smkl>
elem constructs and element of the existential type, and elim accesses those values
<smkl>
s/and/an/
<smkl>
too bad i cannot think anything useful to do with existential types
<TimFreeman>
Ya. I can't think of anything useful to do with the new polymorphism in general. Writing existential types with it doesn't count. :-).
<smkl>
it's useful for some object stuff, that's why it was added
<TimFreeman>
Any specific examples?
<smkl>
now it's possible to have a method that takes an object as value, and the object can have a type like (obj:#class) ... no more coercions needed
<jlamar>
What's a good way to preform object disambiguation, by the way?
<TimFreeman>
smkl: Yes, that does seem useful.
<TimFreeman>
jlamar: Can you give an example of what you're talking about?
<jlamar>
Yeah
<jlamar>
Let's say I've got a function that takes two objects as arguments
<jlamar>
The objects are of class Actor, of which Spaceship and Bullet are subclasses
<smkl>
TimFreeman: another is something like this: class visited = object method visit : 'a. (int -> 'a) -> 'a = fun f -> f 1 end
<jlamar>
The desired effect of the function is supposed to depend on what exactly the two objects are
<jlamar>
For instance, if a spaceship hits a bullet, I want the spaceship to die, but if a bullet hits anothe bullet, they should bounch off each other
<jlamar>
I know there's a few strategies for this in C++, but is there some special ones in ocaml?
<jlamar>
I could have a giant tagged variant in the base class
<TimFreeman>
Smells like you would benefit from polymorphic variants, which I've never used.
<smkl>
if you'd use polymorphic variants, i guess all of the classes would need an extra type parameter that describes the variants used
<jlamar>
I'm just wondering if there's an idiom for this already... I don't necessarily need to upcast, just to know what the two objects are
<smkl>
another is to use exceptions, Hickey's ocaml book describes something like that
<smkl>
if you just need type comparison, you can generate unique ids