-
Notifications
You must be signed in to change notification settings - Fork 5
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
Generalize external types #187
Comments
I agree that The way I think about it, Spaghetti's goal is to make your compiler more clever, so that it can catch errors before the code ever gets executed. Adding a |
I'd like to challenge this argument on the grounds of cross-language semantics: There shouldn't be surprises about what happens after Spaghetti compiles the headers and the host languages' compiler_s_ take over. If we suspend judgement about which constructs can extend which other constructs, we increase the chances of ending up with a situation where the headers compile in one host language, but not in another. Is this not a problem? |
I think Without examples that prove that adding qualifications to |
I guess my concern is that Spaghetti does have some semantics independent of the host languages, it has to understand some things (though this is not explicitly defined now). Spaghetti structs are not Spaghetti interfaces. But in some host languages, both are compiled to that language's "interface" construct.
If we drop the differentiation at the extern level, programmers may come to rely on the implementation detail that both structs and interfaces are represented as interfaces in one language, then run into unexpected problems in languages where the two are represented differently elsewhere. Example:
By using qualifications to Programmers would be able/forced to make more of their intent explicit and get more help from the compiler. |
Spaghetti currently supports external interfaces, but not external structs which seems like an arbitrary limitation.
It would be sensible to introduce the notion of an arbitrary external type:
We could allow to use external types in arbitrary positions, e.g.
however this might mean that if
ns.foo.Bar
is not of an appropriate kind in the host environment, the error is only detected after the headers have already been generated and the host language compiler runs.So we could allow to specify the "kind" of an external type when declaring it, but extend this to
struct
:We could still allow for types of unspecified kinds as
which can only appear in member or function declarations.
The text was updated successfully, but these errors were encountered: