Property definitions

deriving $ Derivable :: defaultinit
# Interface of objects that expose some kind of internal representation in a very unreliable way.
#
# The point of this interface is to allow objects to give a basic representation of
# themselves within a simple key-value dictionary.
# The specific semantic of each key and value is let unspecified.
#
# Moreover the class annotation `auto_derive` will automatically implements the
# interface with the attributes locally defined in the class.
#
# ~~~
# class A
#    auto_derive
#    var an_int: Int
#    var a_string: String
# end
#
# var a = new A(5, "five")
# var map = a.derive_to_map
# assert map.length == 2
# assert map["an_int"] == 5
# assert map["a_string"] == "five"
# ~~~
interface Derivable
	# Returns a map that loosely represents the object `self`.
	#
	# Warning: by default the method returns an empty Map.
	# It is done this way so that subclasses can just call `super` and add their own attributes.
	#
	# Forgetting to redefine `derive_to_map` will broke the expectation of the user of the class
	# Since an empty map is not POLA.
	#
	# Note that the semantic of keys and values is let unspecified.
	# Moreover, there is no specification nor mechanism to avoid key collision.
	fun derive_to_map: Map[String, nullable Object]
	do
		return new HashMap[String, nullable Object]
	end
end
lib/deriving/deriving.nit:24,1--61,3