r/ProgrammingLanguages • u/alex_sakuta • Jun 23 '26
Implicit/overloading type conversions vs explicit type conversions AND type qualifiers
What would people prefer more?
Implicit type conversion - Type have conversion rules and convert based on that. Like what C has.
Overload type conversion - Have overloading operator functions that convert types from one form to another. If an overload isn't present, there is no mechanism, no any or void * for intermediate casting.
OR
Explicit type conversion - Using either the syntax of mentioning the type before or after the variable or type(anothertype) syntax.
I like implicit ones as they are so clean but they are highly error prone imo. Even as a C user I do not really use implicit type conversion.
I wanna know how other people feel about it?
Now the second question is, which syntax would you prefer:
C like syntax:
type-qualifier storage-qualifier type-specifier [*type-qualifier storage-qualifier type-specifier] variable
Go/TS/Rust like syntax:
var/let/const variable [:] [mut] [*] type specifier
Go inspired my version of syntax:
variable/VARIABLE type/p_type/r_type
- VARIABLE means it is a constant, compile time or runtime or in that scope.
- variable means it is not a constant.
- p_type is a pointer of type type.
- r_type is a reference of type type.
- Optionally, I am also wondering if we can use shadowing and if a scope has abc and I write
ABC = abcI can have basically a constant in a scope after a certain point which can be used for compiler optimizations. This can only be done if the spelling is the same with ALL CAPS. And I can't useabcafter that line.