An internal hash code for the object based on its identity.

Unless specific code, you should not use this method but use hash instead.

As its name hints it, the internal hash code, is used internally to provide a hash value. It is also used by the inspect method to loosely identify objects and helps debugging.

var a = "Hello"
var b = a
assert a.object_id == b.object_id

The specific details of the internal hash code it let to the specific engine. The rules are the following:

  • The object_id MUST be invariant for the whole life of the object.
  • Two living instances of the same classes SHOULD NOT share the same object_id.
  • Two instances of different classes MIGHT share the same object_id.
  • The object_id of a garbage-collected instance MIGHT be reused by new instances.
  • The object_id of an object MIGHT be non constant across different executions.

For instance, the nitc compiler uses the address of the object in memory as its object_id.

TODO rename in something like internal_hash_code

Property definitions

core $ Object :: object_id
	# An internal hash code for the object based on its identity.
	#
	# Unless specific code, you should not use this method but
	# use `hash` instead.
	#
	# As its name hints it, the internal hash code, is used internally
	# to provide a hash value.
	# It is also used by the `inspect` method to loosely identify objects
	# and helps debugging.
	#
	# ~~~
	# var a = "Hello"
	# var b = a
	# assert a.object_id == b.object_id
	# ~~~
	#
	# The specific details of the internal hash code it let to the specific
	# engine. The rules are the following:
	#
	# * The `object_id` MUST be invariant for the whole life of the object.
	# * Two living instances of the same classes SHOULD NOT share the same `object_id`.
	# * Two instances of different classes MIGHT share the same `object_id`.
	# * The `object_id` of a garbage-collected instance MIGHT be reused by new instances.
	# * The `object_id` of an object MIGHT be non constant across different executions.
	#
	# For instance, the `nitc` compiler uses the address of the object in memory
	# as its `object_id`.
	#
	# TODO rename in something like `internal_hash_code`
	fun object_id: Int is intern
lib/core/kernel.nit:63,2--92,29

core $ Bool :: object_id
	redef fun object_id is intern
lib/core/kernel.nit:500,2--30

core $ UInt32 :: object_id
	redef fun object_id is intern
lib/core/fixed_ints.nit:596,2--30

core $ Int8 :: object_id
	redef fun object_id is intern
lib/core/fixed_ints.nit:112,2--30

core $ Int16 :: object_id
	redef fun object_id is intern
lib/core/fixed_ints.nit:233,2--30

core $ UInt16 :: object_id
	redef fun object_id is intern
lib/core/fixed_ints.nit:354,2--30

core $ Int32 :: object_id
	redef fun object_id is intern
lib/core/fixed_ints.nit:475,2--30

core $ Char :: object_id
	redef fun object_id is intern
lib/core/kernel.nit:895,2--30

core $ Byte :: object_id
	redef fun object_id is intern
lib/core/kernel.nit:612,2--30

core $ Float :: object_id
	redef fun object_id is intern
lib/core/kernel.nit:524,2--30

core $ Int :: object_id
	redef fun object_id is intern
lib/core/kernel.nit:713,2--30