Hi Kenton,
maybe the problem is in part my inappropriate expectation level. I expected import to work along the lines of C++ namespaces, where I can say "using namespace X", and anything in X will become visible.
> The idea here is that it should be possible to tell which file a definition comes from without having to search all imports. It sounds like you want an "import *" kind of directive, like Java and Python have. But, I hesitate to implement this because lots of Java and Python experts say you should never use their respective "import *" directives because they make it hard to tell what is being imported.
>
> One thing you can do is explicitly alias each exact type:
>
> using import "QueryProxy.capnp".FooType;
> using import "QueryProxy.capnp".BarType;
> using import "QueryProxy.capnp".BazType;
>
> And then FooType, BarType, and BazType will all be usable without any qualification. I have been thinking of simplifying this to something like:
>
> using import "QueryProxy.capnp".(FooType, BarType, BazType);
>
> Do you think that would be enough to make you happy?
Realistically, I don't think so. Basically, what I'm doing is using Zero MQ with Cap'n Proto to cobble together a middleware infrastructure. I have interfaces, operations with in and out params, the usual stuff. (If you've ever seen ZeroC Ice and its Slice definition language, you'll know what I mean.)
Ideally, I would like to have something like re-openable namespaces or modules, so I can group interfaces into namespaces, and have interfaces act as a namespace for its operations. Each operation then ends up describing its parameters as a Cap'n Proto struct with appropriate members.
For some namespaces, there are lots of definitions that I would have to import separately with what you suggest, so I'm doubtful this work all that well.
>
> Does the importing file actually use any of the types defined in QueryProxy or ReplyProxy? The compiler only outputs includes that are needed. This is so that things like "/capnp/c++.capnp" which are only used for annotations don't force a useless #include that slows down the C++ compile.
Yes, the types are used. Without the import statements, the specification would not compile, which is why I added the import statements :-)
Basically, what I have is a case of where the .capnp files compile without complaint, but the generated code does not compile. This should never happen, as far as I can see. All legal .capnp specifications should generated code that compiles without error. (And without the import statements, the specification won't compile.)
Cheers,
Michi.