Developer readable representation of self.

Usually, it uses the form "<CLASSNAME:#OBJECTID bla bla bla>"

Property definitions

core :: abstract_text $ Object :: inspect
	# Developer readable representation of `self`.
	# Usually, it uses the form "<CLASSNAME:#OBJECTID bla bla bla>"
	fun inspect: String
	do
		return "<{inspect_head}>"
	end
lib/core/text/abstract_text.nit:1900,2--1905,4

serialization :: inspect $ Serializable :: inspect
	# Improve the default inspection reading serializable attributes
	#
	# Simple immutable data are inspected as they would be written in Nit code.
	#
	# ~~~
	# assert 123.inspect == "123"
	# assert 1.5.inspect == "1.5"
	# assert 0xa1u8.inspect == "0xa1u8"
	# assert 'c'.inspect == "'c'"
	# assert "asdf\n".inspect == "\"asdf\\n\""
	# ~~~
	#
	# Inspections of mutable serializable objects show their dynamic type,
	# their `object_id` and their first level attributes. When testing,
	# the `object_id` is replaced by an id unique to each call to `inspect`.
	#
	# ~~~
	# class MyClass
	#     serialize
	#
	#     var i: Int
	#     var o: nullable Object
	# end
	#
	# var class_with_null = new MyClass(123)
	# assert class_with_null.to_s == class_with_null.inspect
	# assert class_with_null.to_s == "<MyClass#0 i:123, o:null>"
	#
	# var class_with_other = new MyClass(456, class_with_null)
	# assert class_with_other.to_s == "<MyClass#0 i:456, o:<MyClass#1>>"
	#
	# var class_with_cycle = new MyClass(789)
	# class_with_cycle.o = class_with_cycle
	# assert class_with_cycle.to_s == "<MyClass#0 i:789, o:<MyClass#0>>"
	# ~~~
	#
	# Items of collections are flattened and appended to the output.
	#
	# ~~~
	# assert [1, 2, 3].inspect == "<Array[Int]#0 [1, 2, 3]>"
	#
	# var set = new HashSet[Object].from([1, 1.5, "two": Object])
	# assert set.inspect == """<HashSet[Object]#0 [1, 1.5, "two"]>"""
	#
	# var map = new Map[Int, String]
	# map[1] = "one"
	# map[2] = "two"
	# assert map.inspect == """<HashMap[Int, String]#0 {1:"one", 2:"two"}>"""
	# ~~~
	#
	# Inspections producing over 80 characters are cut short.
	#
	# ~~~
	# var long_class = new MyClass(123456789, "Some " + "very "*8 + "long string")
	# assert long_class.to_s == "<MyClass#0 i:123456789, o:\"Some very very very very very very very very long s…>"
	# ~~~
	redef fun inspect
	do
		var stream = new StringWriter
		var serializer = new InspectSerializer(stream)
		serializer.serialize self
		stream.close
		var str = stream.to_s

		# Cut long inspects
		var max_length = 80
		if str.length > max_length then
			str = str.substring(0, max_length-2) + "…>"
		end

		return str
	end
lib/serialization/inspect.nit:98,2--169,4