change in syntax for types declaration
Can we have new syntax for function type hinting
Current;
New declaration:
I am asking for removal for capitalization of type name
3 Replies
The capitalization is actually important for Mojo's goal of being a strict Python superset. This is because the lowercase type hints are already what's being used in Python and they don't actually change the behavior of the code, whereas Mojo's capital letter type hints do affect behavior. Consider the following code:
This works in both Python and Mojo because the type hints don't enforce anything but capitalizing float or making Mojo treat lowercase like it currently treats uppercase will make Mojo complain about you using the wrong type. This is important because a lot of big important Python libraries lie to you with their type hints like this.
Oh, thanks for replying and explaining the concept
Also, the types themselves are different. I.e.,
Int
versus int
isn't a matter of the compiler looking at capitalization... int
is a Python class. Int
is a Mojo struct.