"When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck."
"the form of subject-predicate-object expressions. These expressions are known as triples in RDF terminology. The subject denotes the resource, and the predicate denotes traits or aspects of the resource and expresses a relationship between the subject and the object. For example, one way to represent the notion "The sky has the color blue" in RDF is as the triple: a subject denoting "the sky", a predicate denoting "has the color", and an object denoting "blue"."
Duck typing over triples is the ability to say that the instance that represents the set of triples can be treated like an instance of a interface. This allows static type safe access to dynamic triple structures, it also allows abstraction through semantic representation of what that thing is; i.e. it's not just a set of arbitrary triples, it is a Student. MVEL does not yet support the "dons", as in "wears" keyword, so please take this as illustrative. The keyword may change eventually but it was proposed by Davide Sottara, who is POCing this idea.
I'll use MVEL like syntax to demonstrate:
bean = [ name : "Zod", age : 150 ]
bean dons Human
assertEquals( "Zod", bean.name )
assertEquals( 150, bean.age)Without the don's keyword to duck type the map to the interface this would not compile as the compiler would report a static typing error of unknown fields for “name” and “age”.
Now that we know duck typing can be used to allow static type safety access to map. What else can we do? In a rule based system if we used triples to represent facts (which is what semantic ontologies do) we can't declare up front what interfaces a map wears, and those interfaces might change over time too. So we can use special rules to dynamically apply traits to a triple set.
rule Human when
$tp : Map( this contains [ "name" : String, "age" : int ] )
$tp dons Human// that $tp instance is now recognised by all other rules that match on Human
rule HelloWorld when
$s : Human // this will actually match against the Map "donned" to Human
println( "hello " + $s.name );