Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables with dictionary rows #20

Closed
hollasch opened this issue Sep 27, 2018 · 0 comments
Closed

Tables with dictionary rows #20

hollasch opened this issue Sep 27, 2018 · 0 comments
Assignees

Comments

@hollasch
Copy link
Owner

The table structure provides a way to ensure consistent data features, along with a way to default missing values. Given this, it would be useful to have tables with dictionary rows, for cases where it's useful to specify sparse information using the standard defaulting mechanism of tables. This offers several benefits over an array of objects:

  1. Explicit field names increases readability, and can be order independent.
  2. Fields can have default types and values.
  3. Fields (with optional type information) can be required.
  4. Unrecognized fields can be reported as errors.

For example:

[#
    a=true, b=1.0, c="foo", d=none, e=normal, f=100%, g=[[1 0][0 1]]
    :
    { b:22.3, d:all }
    { g:rotate(30), f:50%, c:"bar" }
    { a:false, e:heavy }
#]

The result is a data table with three rows, where each row has all values defined, either explicitly or via defaults.

In addition to the above advantages, tables can catch errors based on violations of the schema declaration:

[#
    a=(boolean:), b, c="foo", d=none, e=normal, f=100%, g=[[1 0][0 1]]
    :
    { a:null ... }
    //  ^ Error: type mismatch (detected in clients that care)

    { b:3.7 }
    //      ^ Error: required feature 'a' not defined (it has no default)

    { a:true, b:4.6, x:red }
    //               ^ Error: unrecognized feature 'x'
#]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant