<yezariaely>
my signature is not compatible and I have no clue why.
mattrepl has quit [Quit: mattrepl]
<gasche>
yezariaely: your signature says that you provide the *module type* Inner
<gasche>
(which is implemented by : module type Inner = sig ... end)
<gasche>
what you want to say is that you provide a module with signature ..., so "module Inner : sig ... end"
<yezariaely>
yeah just disovered that.
<yezariaely>
however I didn't get it.
<yezariaely>
ah
<yezariaely>
damn it
<yezariaely>
I have to provide a module TYPE "Inner" if I right it like that?
<yezariaely>
argh...
<yezariaely>
write not right ^^
<gasche>
types, exceptions, values, can be component of modules
<gasche>
modules can also be (so you have a submodule), but module *types* (signatures) can also be components of modules
<gasche>
for example the Map module of the standard library provides the Map.S signature
<yezariaely>
yeah now I understand.
<yezariaely>
thanks!
<gasche>
you're welcome
<gasche>
(//me going back to non-computer stuff)
walter has joined #ocaml
ggole has joined #ocaml
xavierm02 has joined #ocaml
<xavierm02>
Hey
Zeev has quit [Read error: Connection reset by peer]
<xavierm02>
I'm trying to represent "mathematical sets" in ocaml
<xavierm02>
so they would have a type etc.
<xavierm02>
but if I asked for the union set of {0,1,2} as Z/3Z and {0,1} as Z/2Z, I would like the resulting set to have 5 elements.
<xavierm02>
To ensure that that, I want to ask that the two sets are subsets of the SAME set
<xavierm02>
so I have this:
<xavierm02>
class ['a] union_set set1 set2 = object(self) inherit ['a] set if set1.superset <> set2.superset then failwith "The two sets given to union_set must be subsets of the same set." else (); val set1 : 'a set = set1 val set2 : 'a set = set2 method contains = fun x -> (set1#contains x) || (set2#contains x) end ;;
csakatok_ has quit [Remote host closed the connection]
pygmalion has quit [Ping timeout: 256 seconds]
eikke has joined #ocaml
introom has joined #ocaml
Arsenik has joined #ocaml
tane has joined #ocaml
tane has quit [Quit: Verlassend]
pygmalion has joined #ocaml
zpe has joined #ocaml
pygmalion has quit [Ping timeout: 264 seconds]
Neros has joined #ocaml
Drup has joined #ocaml
zxqdms has joined #ocaml
q66 has joined #ocaml
Arsenik has quit [Read error: Operation timed out]
Arsenik has joined #ocaml
bholst_ is now known as bholst
ollehar has joined #ocaml
eikke has quit [Ping timeout: 264 seconds]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
Zeev has joined #ocaml
pygmalion has joined #ocaml
f[x] has quit [Ping timeout: 256 seconds]
pygmalion has quit [Ping timeout: 260 seconds]
<xavierm02>
Okay I have a problem. I want to define a set as an object with: - a type - a function that takes something of this type and returns a boolean telling you whether it is in the set or not
<xavierm02>
But then I define subsets because I want to allow union, intersection etc. only on two subsets of the same set
<xavierm02>
But then there are some sets that are kind of "initial": they aren't subsets of anything but them selves.
<xavierm02>
But when I try to put themselves as superset in the constructor, I get "Error: The instance variable self cannot be accessed from the definition of another instance variable"
Zeev has left #ocaml []
<xavierm02>
hm
<xavierm02>
I might have found a solution
<xavierm02>
get a function get_superset instead of a field
tane has joined #ocaml
<xavierm02>
Nope. Self type cannot be unified with a closed object type
<xavierm02>
-.-
cthuluh has quit [Read error: Operation timed out]
<xavierm02>
got it
dsheets has joined #ocaml
<xavierm02>
made superset mutablet
<xavierm02>
and user the initializer
<xavierm02>
It'd be great if I could remove the option though
<xavierm02>
But I wouldn't know what to put as initial value
<xavierm02>
and making the superset non-mutable
<xavierm02>
I guess I could put the get_superset back
<xavierm02>
and hide superset with a signature
cthuluh has joined #ocaml
zpe has quit [Remote host closed the connection]
<xavierm02>
Error: This expression has type < contains : 'a -> bool; get_superset : unit -> 'a set option; string_of_element : 'a -> string; .. > but an expression was expected of type 'a set Self type cannot be unified with a closed object type
<orbitz>
adrien_: Right, which means modifyign the elngth should be a possible and trivial thing
<orbitz>
pippijn: because the last length is how many of the previosu 4 bytes are part of teh string
<adrien_>
orbitz: no, because reducing the size would mean adding a NULL byte in the middle of the string
<pippijn>
ah
<mrvn>
Every ocaml block has a header. The header has the length of the block in words (length/4) and the string just has the length%4 as extra info.
<pippijn>
right
<orbitz>
adrien_: which is exactly what you'd want
<pippijn>
the number of words
<pippijn>
mrvn: so /8 on 64 bit?
<mrvn>
pippijn: should be
<mrvn>
The length%4 part can be negative too I think.
<adrien_>
orbitz: ah; I would have wanted to keep the original string too
<orbitz>
adrien_: if i make a string smaller obviously I can't keep the original
<mrvn>
A string of length 7 would have one 4 zero byte and then the length correction.
<mrvn>
-one
<adrien_>
orbitz: you could
<adrien_>
you could only allocate a header which gives the location of the string and its length
<mrvn>
orbitz: make a wrapper class that stores (offset, length, string)
<mrvn>
orbitz: or just copy. With <64 byte copying might even be faster than the overhead of the wrapper
<ggole>
Avoiding reallocating is why so many string functions take position/length params
<orbitz>
I can't, Someoen is giving me a string
<ggole>
(Like the Unix stuff)
<orbitz>
It's fine, i was just tseeing if it was passoible
<orbitz>
it doens't really matter
<ggole>
If it's C code, you could just stuff a zero in there
<adrien_>
dirname really is an awful API
<adrien_>
modifies its argument in C
<adrien_>
oh and worse
<adrien_>
dirname("/foo/bar"); is undefined behaviour in C
<mrvn>
adrien_: obviously.
<adrien_>
but by default, GCC won't help you notice it
<mrvn>
It's plain wrong and the compiler will tell you so
<adrien_>
and if it's 3 level deeps...
<adrien_>
mrvn: definitely not
<adrien_>
-Wwrite-strings in GCC is not default, is not in -Wall, is not in -Wextra
<adrien_>
(for C)
<adrien_>
have to go
<mrvn>
right, g++ does warn by default: foo.c:2:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
<ggole>
A bad string api in C?
mattrepl has quit [Quit: mattrepl]
* ggole
gasps in shock
<mrvn>
C doesn't have strings
<ggole>
(dirname is a bit of a shocker though)
<mrvn>
At least dirname() only returns a static string or the original modified. It doesn't alloc as well.
pygmalion has joined #ocaml
ben_zen has quit [Ping timeout: 276 seconds]
malo has quit [Ping timeout: 240 seconds]
yezariaely has quit [Quit: Leaving.]
zpe has joined #ocaml
zpe has quit [Ping timeout: 245 seconds]
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
yezariaely has joined #ocaml
emmanuelux has quit [Ping timeout: 240 seconds]
osnr has quit [Quit: Leaving.]
ttamttam1 has quit [Quit: ttamttam1]
emmanuelux has joined #ocaml
emmanuelux has quit [Remote host closed the connection]
osa1 has joined #ocaml
pygmalion has quit [Ping timeout: 276 seconds]
eni has quit [Ping timeout: 246 seconds]
tobiasBora has joined #ocaml
f[x] has joined #ocaml
ollehar has joined #ocaml
pygmalion has joined #ocaml
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
iZsh has quit [Quit: Coyote finally caught me]
pygmalion has quit [Ping timeout: 264 seconds]
iZsh has joined #ocaml
iZsh has quit [Excess Flood]
iZsh has joined #ocaml
alang_ has joined #ocaml
walter has joined #ocaml
travisbrady has joined #ocaml
darkf has quit [Quit: Leaving]
f[x] has quit [Ping timeout: 240 seconds]
mcclurmc has quit [Ping timeout: 260 seconds]
osa1 has quit [Ping timeout: 260 seconds]
tobiasBora has quit [Ping timeout: 246 seconds]
travisbrady has quit [Quit: travisbrady]
eni has joined #ocaml
walter has quit [Quit: This computer has gone to sleep]
tobiasBora has joined #ocaml
tobiasBora has quit [Ping timeout: 245 seconds]
tobiasBora has joined #ocaml
joseanpg has joined #ocaml
pygmalion has joined #ocaml
pygmalion has quit [Ping timeout: 256 seconds]
joseanpg has quit [Quit: #javascript]
Anarchos has joined #ocaml
Arsenik has quit [Remote host closed the connection]
<Anarchos>
how to debug exceptions in the GC ?
cthuluh has quit [Remote host closed the connection]
<mrvn>
add printf to your C code.
<Anarchos>
i did
<Anarchos>
no other ideas ?
<Anarchos>
it is crashing in caml_oldify_one
<Anarchos>
so very difficult to track what is the faulty root not declared as global...
<mrvn>
what kind of exceptions does the GC throw? I only now that ocaml segfaults when you corrupt the memory.
<mrvn>
try valgrind
<Anarchos>
mrvn i can't use valgring on my OS
<mrvn>
bummer
<Anarchos>
it is a multithreaded C application, linked with ocaml
<mrvn>
does it happen on start or after a while?
<mrvn>
Do you pass C pointer to ocaml directly or only in custom blocks with finalizer?
<Anarchos>
mrvn it is encapsulated as a field in a block.
<mrvn>
When you free that pointer in C it can happen that the GC allocates a new heap that contains that address and then the field in the block suddenly becomes GC manages and bad things happen.
<Anarchos>
mrvn i don't free them :)
<mrvn>
hmm, that prevents that
ggole has quit []
<Anarchos>
anyway is there a mean to discover which address were freed on the C side and reallocate within ocaml ?
<mrvn>
maybe print all the C pointers you pass to ocaml and then check what address it tries to modify in the crash
<mrvn>
glibc has stubs to monitor alloc and free calls but you probably don't have glibc.
<Anarchos>
i have glibc :)
<mrvn>
but no valgrind? hmm
<Anarchos>
mrvn i am on haiku, honestly i don't know if valgrind runs on it
<mrvn>
Anarchos: man malloc_hook
travisbrady has joined #ocaml
<Anarchos>
mrvn ok thanks
<mrvn>
But if you never free the C pointers passed to ocaml then nothing bad should ever happen.
<mrvn>
Can you gleam anything from the size and tags of the block it crashes on?
pygmalion has joined #ocaml
<Anarchos>
mrvn no, sadly
pygmalion has quit [Ping timeout: 264 seconds]
<mrvn>
zsh: segmentation fault ./client.native
<mrvn>
I think I found a bug in OcamlSDL
cthuluh has joined #ocaml
<mrvn>
Stupid off-by-one error
Anarchos is now known as mmlr_fan
mmlr_fan is now known as Anarchos
travisbrady has quit [Quit: travisbrady]
tobiasBora has quit [Ping timeout: 245 seconds]
pygmalion has joined #ocaml
mye has quit [Quit: mye]
chambart has joined #ocaml
<mrvn>
My "GUI" no handles mouse-over effects.
<mrvn>
layout done, mouse movement done, next: mouse clicks
<mrvn>
I think i also need something to handle keyboard focus. Keyboard events shouldn't always go to the widget the mouse is over.
mattrepl has joined #ocaml
Yoric has quit [Ping timeout: 246 seconds]
chambart has quit [Ping timeout: 245 seconds]
cthuluh has quit [Read error: Operation timed out]
tobiasBora has joined #ocaml
cthuluh has joined #ocaml
eni has quit [Quit: Leaving]
osnr has quit [Quit: Leaving.]
zpe has joined #ocaml
<mrvn>
If I have a class t can I get the type of that somehow?
zpe has quit [Remote host closed the connection]
<orbitz>
as in the name?
<mrvn>
as in to cast something to that type or ensure it has the right interface
<mrvn>
I was looking for class foo = object (self : 'self) ... end
ollehar1 has joined #ocaml
ollehar has quit [Ping timeout: 246 seconds]
<Anarchos>
mrvn use coercition : (o: t1 :> t)
structuralist has joined #ocaml
ollehar has joined #ocaml
ollehar1 has quit [Ping timeout: 260 seconds]
tane has quit [Quit: Verlassend]
Simn has quit [Quit: Leaving]
<ollehar>
can I make a copy of an object as with a record `{r with fields =... }
<ollehar>
?
<ollehar>
asdasd
ollehar has quit [Quit: ollehar]
ollehar has joined #ocaml
<ollehar>
bla
<ollehar>
can I make a copy of an object as with a record, `{r with field = ... }`?
<ollehar>
e.g., I want to replace a function in an object
<Anarchos>
ollehar nothing about that in the manual ?
<mrvn>
ollehar: Obj.copy
Anarchos has quit [Quit: Vision[0.9.7-H-130604]: i've been blurred!]
<mrvn>
ollehar: and then you need a method in the object that changes the value you want changed
<ollehar>
I don't have control over the original class :P
<mrvn>
derive a new one
def-lkb_ is now known as def-lkb
zpe has joined #ocaml
zpe has quit [Ping timeout: 240 seconds]
osnr has joined #ocaml
osnr has quit [Changing host]
osnr has joined #ocaml
<ollehar>
there's no class, only a class type. must I copy-paste the declaration?
<mrvn>
what happens if you inherit it?
<ollehar>
there's nothing to inherit since there is no class :(
<ollehar>
"Unbound class Netcgi.cgi"
<ollehar>
I checked the netcgi.mli, and there's a class type "cgi"
<ollehar>
ah, but there must be other classes with this type, right?
<ollehar>
"real" classes
<ollehar>
will look more
<mrvn>
is it even a class? Could be just a module
<ollehar>
it's a class type
<ollehar>
not sure I know the difference
<ollehar>
will sleep on this, thanks for your tips!
eikke has joined #ocaml
ollehar has quit [Ping timeout: 264 seconds]
pygmalion has quit [Ping timeout: 260 seconds]
eikke has quit [Ping timeout: 246 seconds]
Neros has quit [Read error: Connection reset by peer]