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

Enhance VisitorTransforms #94

Open
dlurton opened this issue Sep 2, 2021 · 0 comments
Open

Enhance VisitorTransforms #94

dlurton opened this issue Sep 2, 2021 · 0 comments

Comments

@dlurton
Copy link
Member

dlurton commented Sep 2, 2021

Given:

(define (domain a (product x y::int))
(define (domain b (product x y::symbol)))
(transform a b)

You get a generated abstract cross domain AToBVisitorTransform with method like this:

abstract fun transformX(node: A.X): B.X
                        //      ^     ^

In both domains the types have the same name but are not identical, so PIG can rightly assume you want to convert A.X. to B.X.

However, if domain b does not have an x type then you won't get a similar method to convert x to anything in the B domain because PIG doens't currently make any assumptions about what the appropriate return type for such a function would be.

It would however be possible to generate an abstract method like this:

fun transformX(node: A.X): B.BNode = ...

And implementations of this function can use covariant return types to narrow the return type of transformX as needed.

(BNode is the generated superclass for all classes in the B domain.)

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