8000 Support type constructors (a.k.a. Generics) · Issue #30 · reproto/reproto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support type constructors (a.k.a. Generics) #30
Open
@udoprog

Description

@udoprog

The following showcases a generic pair implementation and how it could be used:

Some backends might support generics natively (Rust, Java). For now, this information will be erased to maximize support with as little effort as possible. It might be possible to provide the generic information as well so that it can be used. Alternatively this could be performed in a late translation step, making it possible for backends to decide if they need to perform erasure or not.

tuple Pair<L, R> {
  left: L;
  right: R;
}

type Entry {
  p1: Pair<string, u32>;
  p2: Pair<string, string>;
  p3: Pair<string, string>;
}

This would be syntactically translated into the following:

tuple PairStringU32 {
  left: string;
  right: u32;
}

tuple PairStringString {
  left: string;
  right: string;
}

type Entry {
  p1: PairStringU32;
  p2: PairStringString;
  p3: PairStringString;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0