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

Define/Implement scema format #46

Open
Abscissa opened this issue Sep 23, 2016 · 3 comments
Open

Define/Implement scema format #46

Abscissa opened this issue Sep 23, 2016 · 3 comments

Comments

@Abscissa
Copy link
Collaborator

Obviously in SDLang itself, of course.

This will allow for a much simpler, more robust API that's more statically-typed and has vastly better error-checking built-in for both parsing and writing.

It should also help with a generic "SDLang <--> other formats" converter (ie, #30).

I have some work done on the design, but still need to finish & implement.

@timotheecour
Copy link

timotheecour commented Feb 13, 2018

@Abscissa [sorry if it's only very mildly related] I'm wondering whether SDL would be a good fit for protobuf human readable format (see msoucy/dproto#71 (comment) where i was trying to improve on default protobuf text format which I don't like because of treatment of repeated fields)

(also very mildly related to #30 since that deals with conversion from X to/from SDL)

mixin ProtocolBufferFromString!"message Person { optional string name=1; optional int32 age=2; } ";   // eg from cf https://github.com/msoucy/dproto

Person a;
a.parseSDL(some_sdl_string);
assert(some_sdl_string == a.serializeSDL);

one important use case would be reading in structured data (with an enforced schema) to command line programs:

// usage:
// echo 'name bob \n age 22' | rdmd main.d
void main(string[]args){
  Person a;
  a.parseSDL(args[1]); // type-safe schema compliant parsing here
  writeln(a.name);
}

@Abscissa
Copy link
Collaborator Author

My understanding of protobuf isn't especially deep (it's been a long time), but from what I do know of it: Yea, the SDLang format should work fine for it, I don't see why not.

Incidentally, some time ago I did have a go at designing a schema format for SDLang written in SDLang, but in doing so I came to the conclusion it would make far more sense to just use D structs/classes with UDAs as the schema, like most typical serialization libs.

Eventually, an SDLang-based SDLang schema could still be developed if sharing an SDLang schema across different programming languages becomes an important concern (much like protobuf), but I think UDA-based serialization is a far more sensible (and arguably necessary) as a first step.

@s-ludwig
Copy link
Contributor

Just mentioning for completeness: https://code.dlang.org/packages/vibe-sdlang

This implements a vibe.data.serialization based serializer with some extra UDAs to control attributes and values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants