Skip to content

Possible options for implicit casting #1283

Open
@certik

Description

@certik

Now when #1271 is in, I suggest we keep it for some time and see how it feels.

If we decide we want to implement some implicit casting, it seems we can't do any implicit casting in assignment, because in CPython the LHS type is taken from the RHS, so LPython must follow the same approach in order to be compatible, so we cannot do any implicit casting there.

What we can consider doing is:

x: f32
x = 5.5
x = x * 5
x = x / 5

Where we can do implicit casting from integer to real. That casting I think is always safe and it would cast to the floating point type of the other operand in the binary operation. I think it is natural to write things like 2*a*b for floating point a, b.

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