-
Notifications
You must be signed in to change notification settings - Fork 86
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
Generated code format #29
Comments
Hi! Looks like there a several components to what you're proposing. The first idea is to bypass the need to explicitly create a
I think this might make a lot of sense! The primary purpose of Another idea in your proposal, if I understand correctly, is to combine
and
and we would need to come up with a new name for one of them, maybe A third idea in your proposal is to include something like type aliases in the generated code. I guess the way this would work is that there would be generated code that looks like this:
I suppose this might provide some convenience. You would need to decide how to deal with the case when this would cause a name collision, for example if there was already a |
David, Thanks for the analysis! What I am gleaning at a high level is that there is some value in massaging the generator, but that it won't be a quick hours work. Let me see if I can provide some useful thoughts on your feedback. Regarding the embedding of On the case of blending the You're probably wondering on my purpose. I am working on a piece of middleware and I want to allow external plugin developers to make their own messages. We'll provide a set of base message types in capnp, so they be constrained to use it. I expect these users to be academics, and I want to minimize the amount of learning so they can spend more time on their algorithms. Ideally, they would have a very standard bean like interface. Again at this point it sounds like I need to try modifying the code to see what works and what doesn't. Any other pointers to what would probably not work would be highly appreciated. Thanks! |
Greetings!
Thanks so much for taking this project on an all the work.
While experimenting with this I was wondering about the output format and the reasons for it. It seems that since you are generating the classes you could wrap some of the boilerplate in the generated code. For example, a cleaner end-user interface might be something like:
// Under the hood this does new MessageBuiilder and initRoot
AddressBook addressBook = new AddressBook();
// The People inner class wraps the generics
AddressBook.People people = addressBook.initPeople(2);
// Again, we wrap the generics
AddressBook.Person alice = people.get(0);
alice.setId(123);
alice.setName("Alice");
alice.setEmail("[email protected]");
AddressBook.Person.Phones alicePhones = alice.initPhones(1)
alicePhones.get(0).setNumber("555-1212");
...etc.
This would get rid of a lot of the messy generic boilerplate. Offhand, do you know of anything that would prevent it from being modified (i.e. by me) to do this?
Thanks,
-Andrew
The text was updated successfully, but these errors were encountered: