Re: Ocaml binding innards (was Re: [gdome]user_data and language bindings)
- From: Claudio Sacerdoti Coen <sacerdot CS UniBO IT>
- To: Tobias Peters <t-peters gmx de>
- Cc: gdome gnome org
- Subject: Re: Ocaml binding innards (was Re: [gdome]user_data and language bindings)
- Date: Sat, 6 Apr 2002 14:40:01 +0200
> "newChild" are the very same object inside Ocaml for this particular
> method (insertBefore), and not two different Ocaml objects that happen to
> represent the same Gdome node?
> ...
> n1 = someNode.firstChild
> n2 = someNode.firstChild
> (in whatever Syntax is appropriate for Ocaml),
> n1 and n2 are different Ocaml objects that happen to wrap the same gdome
> node. With different I mean, they would fail at least some of Ocaml's
> equality/identity tests.
Yeah, you got it right!
Let's say something on equality in Ocaml. In Ocaml we are used to two
kinds of equality: structural equality and phisical equality. Physical
equality means that the two objects are the same, i.e. they have the
same address in memory. The other equality means that all of their fields
are equal. The equality for binded objects is physical equality.
So you are right: physical equality is broken (while structural equality
is retained, but also a bit less efficient). By the way:
1) Structural equality seems to be the preferred/standard equality for Ocaml.
(For some reasons I don't want to explain here.)
2) If you really need physical equality, than it is usually up to you to
grant in your code that it is preserved. In this case I could either
use the user_data field as you did, or use the global (per-document)
hash-table technique. The fact that physical equality is less used
suggests me that the hash-table technique is probably better.
By the way, thank you for helping me focusing on this point. I should
probably add it to the documentation of the binding in the next
release.
Regards,
C.S.C.
--
----------------------------------------------------------------
Real name: Claudio Sacerdoti Coen
PhD Student in Computer Science at University of Bologna
E-mail: sacerdot cs unibo it
http://caristudenti.cs.unibo.it/~sacerdot
----------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]