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

Cross-domain type references #65

Open
dlurton opened this issue Jan 14, 2021 · 0 comments
Open

Cross-domain type references #65

dlurton opened this issue Jan 14, 2021 · 0 comments

Comments

@dlurton
Copy link
Member

dlurton commented Jan 14, 2021

We should consider adding the ability to refer to types in other domains. I can add more details to this later if needed but this is the gist of it.

(define 
    (domain toy_lang_ast
        (product term 
            exp::expr 
            type::toy_lang_types.data_type) 
        (sum expr ...)
    ))

(define 
    (domain toy_lang_types
        (sum data_type (int) (string) (struct name::symbol fields::(* struct_field 0)) ...)
))

Note that in the toy_lang_ast domain, the type element of the term product is an instance of the data_type sum from the toy_lang_types domain.

Part of the motivation for this:

  • Without this, data_type would have to be defined within toy_lang_ast. Every permutation of toy_lang_ast then would have new Kotlin classes generated. This means that Kotlin code that works on DataType defined in one domain cannot be used on instances of DataType from a permuted domain, which is a real shame since can lead to code duplication. The proposed feature reduces this significantly, though does not entirely eliminate it.
  • Once Add include_file  #57 has been completed, it will be extremely useful to be able to reference a data type defined in another file, such as domains that are designed to contain schema meta data.
  • This feature also reduces the amount of code generated by permuted domains since some parts of the domains which don't change from permutation to permutation can be placed in another domain which doesn't get permuted as often.

One possible area of complexity I see here is that we will have to consider how this will work with regard to our three different types of visitors. I believe generated visitors do not need to invoke visitors for other domains. If the user requires this they can override the appropriate method from one of the generated visitors and invoke the visitor manually.

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

No branches or pull requests

1 participant