Skip to content

new data format #40

Closed
Closed
@vitiral

Description

@vitiral

So I've been tossing an idea for a data format around in my head for a while now, and this seems like a good application so I thought I would throw it out.

Basically the data format is roughly this: xml in json-syntax. The idea is to have a json/yaml-like syntax but with attributes. So you could write something like this:

foo @{x: 42, y: 72, z}:
    a: "this is a key: string"

@dec_attr: "This is a decorating bar"
bar: "this is bar"

The basic idea is that attribute maps denoted by @ can be placed either after a key or above a key. After a key they must be in the form @{ ... } and above the key they must be in the form @key = value.

The basic idea is to make it easy to have keys with attributes associated with them -- such as types, generics, compiler flags, etc. This kind of language could be used for writing type systems, as a new programming langauge, or almost anything! If you think about it, programming languages are pretty much just variable names with some attributes (as well as some logic handlers... which would not be included in this spec).

Maybe significant white-space is not desired, or requiring "" around keys is desired. You could still use much the same syntax:

{
  "foo" @{"x": 42, "y": 72, "z": true}: {
    "a": "this is a key: string",
  },
  @"dec_attr": "This is decorating bar",  # <-- note the `,` is necessary
  "bar": "this is bar",
}

Also note that {z} is interpreted {z: true} to make passing flags easier. That could also be removed.

One advantage of this system is a clear distinction between the user's logic and the compiler or type-system's logic. The compiler is pretty much only concerned with the attributes (which the user uses to communicate with the compiler). So everything in an attribute is a compiler/language directive, and everything outside an attribute is a user-defined name/value/type.

Anyway, just something I've been tossing around in my head, thought you might like it for some food for thought!

Metadata

Metadata

Assignees

No one assigned

    Labels

    alternativeSuggested alternative formats

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions