Skip to content

Cast to non-builtin types #6

Closed
Closed

Description

@iuliux

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.

Activity

  1. natural commented on Apr 21, 2012

    @natural
    Owner

    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.

  2. iuliux commented on Apr 21, 2012

    @iuliux
    ContributorAuthor

    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?

  3. natural commented on Apr 23, 2012

    @natural
    Owner

    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?

  4. iuliux commented on Apr 23, 2012

    @iuliux
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions