Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this not too little syntax, though? The two JSON documents

  { "foo": true }
  { "foo": "true" }
would both have to map to the same TAO representation:

  foo [true]


Yes, Data TAO as shown on the website maps to a subset of JSON with only one primitive type (string).

However this is by design.

The idea is to provide only the most generic constructs, decouple specialized data types from the core syntax and enforce/interpret them on a separate layer.

An ad hoc (but perfectly sensible IMO) way to apply this idea to the example is: if foo is supposed to be a string then no need to do anything (that's the default primitive). If it's supposed to be a boolean, then parse it as such (e.g. 'true' -> true, 'false' -> false, error otherwise; or even error if typeof JSON.parse(value) !== 'boolean' in JS).

A non-ad hoc data type layer for TAO is something I've thought about a lot and it's still baking.

Two basic (non-exclusive) ways to do this:

1. Inline/mixed with the data -- type annotations, op-based literals

2. Separated from the data -- schema-based

Example designs for the 1st point:

    foo [`t]
    foo`: boolean [true]
    foo`: json [true]
All of these would associate the boolean `true` with `foo`.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: