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

Cast to non-builtin types #6

Closed
iuliux opened this issue Apr 21, 2012 · 4 comments
Closed

Cast to non-builtin types #6

iuliux opened this issue Apr 21, 2012 · 4 comments

Comments

@iuliux
Copy link
Contributor

iuliux commented Apr 21, 2012

A cast to a class type is turned into a constructor of that type. For example:

obj = (Cast) o;

becomes:

self.obj = Cast(o)

However, with builtin types like String, this works fine.

@natural
Copy link
Owner

natural commented Apr 21, 2012

What do you think the behavior for translating casts should be? I realize there's a problem, but I don't see an obvious target for casts.

@iuliux
Copy link
Contributor Author

iuliux commented Apr 21, 2012

I think that just removing them would be better (except the built-in ones that work as they are now). So obj = (Cast) o; would become self.obj = o
Actually, I thing this would behave pretty well, or am I wrong?

@natural
Copy link
Owner

natural commented Apr 23, 2012

I don't think we can simply drop the casts because self.x = some_string is totally different than self.x = int(some_string).

I think a reasonable approach would be:

  1. perform the casts for known Java types
  2. provide a configuration option for handling casts in general
  3. log a warning if a cast is detected that isn't handled by the previous 2 steps

What do you think of that?

@iuliux
Copy link
Contributor Author

iuliux commented Apr 23, 2012

That looks good. (1. is also what I was suggesting with "except the built-in ones that work as they are now").

I'll come with a pull request shortly.

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

2 participants