bevry / cson

CoffeeScript-Object-Notation. Same as JSON but for CoffeeScript objects.
Other
1.34k stars 56 forks source link

Formal definition of CSON #38

Closed hildjj closed 9 years ago

hildjj commented 10 years ago

JSON suffered from being too tied to the JavaScript programming language early on. I suggest a document describing the format being parsed, so that other interoperable implementations can be built.

If this exists already, than I suggest a link in the README. If it doesn't, I'd be willing to take a first stab at text.

RobLoach commented 10 years ago

Some other specification definition examples for other structured data:

hildjj commented 10 years ago

Another example: RFC7159

I'd suggest that there are two paths.

  1. Document a subset of CoffeeScript that maps 1-1 with JSON, including specifying the mappings
  2. Define a completely separate syntax that avoids some of the interop challenges JSON faces at the edges (search RFC7159 for "interop")

Of these, I think I prefer (1), but not by much.

RobLoach commented 10 years ago

http://coffeescript.org/#objects_and_arrays

Maybe this goes beyond just CSON, but CoffeeScript definition in general.

hildjj commented 10 years ago

Experience from JSON tends to indicate that divorcing CSON from coffee-script as soon as possible is going to allow much better interop between CSON implementations written in different languages. If coffee-script needs a more formal definition, that's an unrelated issue. The language at http://coffeescript.org/#objects_and_arrays is a good starting point, of course.

balupton commented 9 years ago

Fixed in v2 - there is now cson-parser package

hildjj commented 9 years ago

Although I agree that splitting out the parser code into a separate module that doesn't re-use the coffee-script parser was fantastic work, I think you may be missing the point of the documentation request. Defining CSON as a wire-level protocol (where the "wire" might include a file, for example) is necessary if I want to write an implementation in a language that doesn't share ECMAscript's odd notion of Unicode (UTF-16 plus naked surrogates with escape sequences that might or might not generate valid Unicode when parsed?), have different notions of numbers (e.g. real 64-bit integers), has floating point types that work, etc. Saying "it's just coffee-script, and therefore just ECMAscript" doesn't make these questions go away. Am I allowed to include functions? Can I include function calls? What about using "import"?

balupton commented 9 years ago

No dynamic abilities. They are for coffee files. CSON is now just a data format. Further discussion should happen over at https://github.com/groupon/cson-parser see https://github.com/bevry/cson/issues/33 also