Skip to content

Conversation

@shivasankarka
Copy link
Collaborator

This PR comments out all the Type Coercions for the data types that currently implemented. This is done for the following two reasons,

  • The current Mojo compiler isn't able to parse and calculate the resulting data type at compile time correctly yet.
  • The resulting generic data type is very confusing to work with for end users currently and requires weird code shenanigans to work around it.

Therefore these will be temporarily commented out. We will get back to improving it and adding it back in later version of NuMojo once Mojo type system is mature enough for us to implement these data type conversions at compile time.

@shivasankarka shivasankarka marked this pull request as draft April 30, 2025 15:57
@shivasankarka shivasankarka marked this pull request as ready for review April 30, 2025 16:10
@forfudan
Copy link
Collaborator

@shivasankarka, I prefer "explicit type cast" to "implicit type coercion". If a user sums up a Matrix of i8 and a Matrix of i16, they should do this explicitly with a.cast[i16]() + b. This avoids a lot of troubles and hidden mistakes. To be frank, I would never want to see type coercion again :D (so maybe permanently suspending type coercions)

@forfudan forfudan merged commit c8d9b63 into Mojo-Numerics-and-Algorithms-group:pre-0.7 Apr 30, 2025
2 checks passed
@shivasankarka
Copy link
Collaborator Author

@forfudan Yes, explicitly type casting is better, it gives control to user.
But I think at some point we have to implement implicit type coercions since numpy offers the same, assuming we do want to implement all features from numpy. Implicit type type coercion will simplify a lot of things for the user if done right.

forfudan added a commit that referenced this pull request May 1, 2025
@forfudan
Copy link
Collaborator

forfudan commented May 1, 2025

@shivasankarka, for sake of convenience, it is indeed good to have type coercions, but maybe we need to define and document a list of detailed rules of coercions for the users, so that they won't get surprised.

Another topic is that not every feature from numpy is the best practice. For example, the pandas is more flexible in data types per column, but polars is stricter. Many people, however, love polars' style because they will never be surprised by implicit type casts. For numojo, we could also listen to users' feedback and see whether implicit type cast is really needed.

forfudan added a commit that referenced this pull request May 29, 2025
forfudan added a commit that referenced this pull request May 29, 2025
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

Successfully merging this pull request may close these issues.

2 participants