cjeris changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
sourcerror_ has joined #ocaml
sourcerror has quit [Read error: 110 (Connection timed out)]
dbueno has joined #ocaml
<dbueno>
(ref ()) = (ref ()) => true
<dbueno>
In SML, sometimes ref() is used to get a unique value -- to ensure two similar things are unique. Is there an analogue for OCaml?
<mrvn>
# (ref ()) == (ref ());;
<mrvn>
- : bool = false
<dbueno>
Ugh, never mind.
<dbueno>
mrvn: Yes, sorry.
<dbueno>
Thanks for the help. =]
<mrvn>
structural vs something equality
<dbueno>
pointer/reference.
<dbueno>
"physical" I think is the actual word they use.
<mrvn>
Physical equality
<mrvn>
yep, that is what file:///usr/share/doc/ocaml/docs/ocaml.html/manual015.html calls it
<mrvn>
Strangely enough there is no physical less than though.
<dbueno>
mrvn: Yeah, that's the only reason I decided not to use it.
<dbueno>
I need to define a comparator over the data type -- so I'm using int instead of unit ref.
<mrvn>
but 1 = 1
<mrvn>
I like ref () though. Interestingly useless type.
<dbueno>
Yeah -- I'll increment the number to ensure uniqueness.
<mrvn>
so each object gets an id:int
<mrvn>
Can one get the address of an object via the Obj module with some hack?
<mrvn>
let addr_of x = let t = ref x in ((Obj.something x):int)
<dbueno>
mrvn: Obj.<anything> scares me.
<dbueno>
Mainly because of the lack of documentation.
<mrvn>
good.
<mrvn>
I just figured out why physical less than wouldn't make any sense. When the GC compacts the memory the address can change and objects would suddenly have a different order.
<mrvn>
At least I think it can.
Z4rd0Z has quit []
zarvok has quit ["My damn controlling terminal disappeared!"]
dbueno has quit ["Leaving"]
danly has joined #ocaml
flux has quit [Read error: 104 (Connection reset by peer)]
flux has joined #ocaml
<Nutssh>
You can disable compaction.
johnnowak has quit []
Smerdyakov has quit ["Leaving"]
sourcerror__ has joined #ocaml
sourcerror_ has quit [Read error: 110 (Connection timed out)]
Z4rd0Z has joined #ocaml
Z4rd0Z has quit []
benny_ has joined #ocaml
benny has quit [Read error: 60 (Operation timed out)]
_JusSx_ has joined #ocaml
Z4rd0Z has joined #ocaml
Z4rd0Z has quit []
jlouis has quit [Read error: 104 (Connection reset by peer)]
jlouis has joined #ocaml
Z4rd0Z has joined #ocaml
love-pingoo has joined #ocaml
bluestorm_ has joined #ocaml
smimou has joined #ocaml
vital303 has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
Submarine has quit [Read error: 60 (Operation timed out)]
jlouis has quit [Remote closed the connection]
Submarine has joined #ocaml
Mr_Awesome has quit ["...and the Awesome level drops"]
vital304 has joined #ocaml
vital303 has quit [Read error: 110 (Connection timed out)]
obnibolongo has joined #ocaml
obnibolongo has quit []
jlouis has joined #ocaml
vital303 has joined #ocaml
pango has quit [Remote closed the connection]
pango has joined #ocaml
vital303 has quit ["Leaving."]
Smerdyakov has joined #ocaml
vital303 has joined #ocaml
joshcryer has quit [Client Quit]
mrvn has quit [Read error: 104 (Connection reset by peer)]
slipstream has joined #ocaml
jlouis has quit [Remote closed the connection]
mrvn has joined #ocaml
<mrvn>
re
<mrvn>
Anyone know offhand how to tell the GC about a caml value that one stores a pointer too in C code? The object has to be kept alive and not get moved.
<flux>
no, but maybe you could check out the ocaml library that is for putting bit objects outside the gc heap
<Smerdyakov>
I am firmly against bits.
<mrvn>
Putting it outside the heap is simple. But how do I tell the GC about it again?
<mrvn>
I need something like CAMLlocal1(v) but across multiple function calls.
<flux>
hmh, BIG objects :)
<mrvn>
As in Bigarray?
<flux>
no.. hmm.. I wonder if it was jane capital software..
<flux>
oh, maybe it won't suit as an example for you
<mrvn>
The scenario is like this: libfuse calls fopen: string -> open_flags list -> 'a option. The 'a gets saved in some fuse structure. Fuse then calls read/write with that 'a and last calls release to free the 'a.
<mrvn>
flux: Do you know if this works if the ancient object has a pointer to a normal one?
<flux>
no
<flux>
that is, no, I don't know
<mrvn>
nm, it can't. results in crashes it says.
<mrvn>
"Registration of a global variable v is achieved by calling caml_register_global_root(&v) just before a valid value is stored in v for the first time." There we go.
obnibolongo has joined #ocaml
<obnibolongo>
hi! anyone here can help me on a camlight question?
<mrvn>
obnibolongo: 42
<obnibolongo>
wtf?
<obnibolongo>
okay...
<mrvn>
Best guess answere to your question. Sorry, my crystal ball is murky.
<obnibolongo>
anyway, i was trying to create a type which was something like "type PRED=ATOM of string of Term_list;; "
<obnibolongo>
but caml apparently doesn't like more than a "of" on the same type definition
<mrvn>
What is a string of Term_list supposed to be? Strings are of chars usualy.
<mrvn>
Or o you want a list of strings?
<obnibolongo>
hum you're right
<obnibolongo>
anyway, i was trying to create a type which was something like "type PRED=(ATOM of string) of Term_list;; "
<mrvn>
Or Term_list array?
<obnibolongo>
i was trying to organize stuff so I'd have a label of the term_list
<mrvn>
type pred = ATOM of strin term_list? A list of strings.
<mrvn>
or string * Term_list? A list with a name?
<Smerdyakov>
obnibolongo, we don't understand what a "double of" would mean. It's not just that we know that OCaml doesn't support it.
<obnibolongo>
hum okay...
<obnibolongo>
then one more thing
<mrvn>
obnibolongo: It sounds to me like you want string * Term_list.
<obnibolongo>
if you had to work with first order logic and the predicate would be, in the language yet to be parsed, man(socrates, plato), and you had to parse it, how would you store it internally
<mrvn>
let name_of_list l = let (name, _) = l in name
<mrvn>
obnibolongo: So you say socrates and plato are men?
<obnibolongo>
mrvn: yes, but for now i just want to store it in someway i can parse it easily. i'm not yet on the stage of evaluting stuff...
<mrvn>
type predicate = string -> bool
<mrvn>
type term_list = string list
<mrvn>
type predicate_info = predicate * term_list
<mrvn>
hmm, no. not that way.
<mrvn>
let is_man = List.mem ["socrates"; "plato"];;
<mrvn>
val is_man : string list list -> bool = <fun>
<mrvn>
# let is_man = fun x -> List.mem x ["socrates"; "plato"];;
<mrvn>
val is_man : string -> bool = <fun>
<mrvn>
better. How about that structure?
<obnibolongo>
i honestly don't know....... is that camlLIGHT?
<mrvn>
ocaml but that should be nearly the same
<obnibolongo>
i don't know
<obnibolongo>
guess so
<obnibolongo>
anyway, thanks, i'll try that.
<mrvn>
or if you need it more abstract, like you parse in the predicates from the input:
<mrvn>
type predicate = { name : string; members : string list; }
<mrvn>
If camllight has records.
<obnibolongo>
yes, it has :D
<mrvn>
type predicate = string * string list;; otherwise.
<mrvn>
Hope that helps.
<obnibolongo>
mrvn: yes it does :D
<obnibolongo>
i had completely forgotten records
<obnibolongo>
and was going nuts trying to think i would be completely doomed when i got to the part of analysing the logic value of stuff
<obnibolongo>
mrvn: thank you very much :D
<mrvn>
I find records often make the code more readbale than tuples. You stick a lable to the entry. And you don't need to extract members with 'let (a,b,c) = d' or match.
<obnibolongo>
and also Smerdyakov :)
<obnibolongo>
yes, I agree :)
gim has joined #ocaml
<obnibolongo>
well, bye now, and thanks again :)
mbishop has quit ["Leaving"]
obnibolongo has quit []
gim has quit [Client Quit]
jlouis has joined #ocaml
vital304 has quit [Connection timed out]
<mrvn>
I wish ocaml unix.cmxa would export the helper functions that convert errno into an Unix.unix_error.
<mrvn>
As in put the prototype of the function into a header file.