RE: Type Coercion is confusing (ISSUE-34)

> In fact, my internal representation is what you suggest. The rationale
> for the existing rep is that it is much shorter, otherwise a given type
> would need to be specified once for each property.

Yes, that's true. Of course you could also see it as a variable declaration
such as "int age, height". Nevertheless I find it confusing and see it as a
source of a lot of hard-to-debug errors.

It's much easier to check what the type of an attribute is if it's stored
the other way round. It's also easier to prevent people setting the type of
an attribute to two incompatible types (copy and paste/inconsistent changes)
such as:

"@coerce":
{
 "xsd:integer": ["age", "value", "size" ],
 "@iri": "homepage",
 ...
 ...
 .. a lot of other stuff ..
 ...
 ...
 "xsd:boolean": ["read", "deleted", "value"]
}


It's really difficult to spot that "value" is coerced to both, xsd:integer
and xsd:boolean. No one would miss such an error in the other form:

{
  ...
  "value": [ "xsd:integer", "xsd:boolean" ]
}


So I would really like to change this form. The few bytes we save here
shouldn't really matter that much; I reckon GZIP eliminates most of the
overhead anyway.



--
Markus Lanthaler
@markuslanthaler

Received on Thursday, 29 September 2011 09:34:41 UTC