No. By using the + operator, you are explicitly asking for the string to be converted to a number. Why do you say it is implicit? (This thread may be heading towards Room 12A).
| [reply] [d/l] |
Sure, I can "explicitly" do 0+ with the intent of converting a string into a number. "Explicit" describes my motivation. But, no, 1+$duration is not an explicit type conversion, it is explicit addition that implies a type conversion, if required.
I can write 1+$duration with no intention of doing a conversion. If I am mistaken in thinking that $duration holds a numeric value and write 1+$duration, since the explicit request for addition includes in it an implicit possibility of type conversion, the compiler can't tell that I didn't mean for a conversion to happen. The type conversion is called "implicit". Having to write 1+(int)$duration is much more explicit. Type conversion is only done when I explicitly say "do a type conversion" not when I say "do addition" and can't separately specify that I want a conversion.
| [reply] [d/l] [select] |
1+$duration is not an explicit type conversion, it is explicit addition that implies a type conversion, if required.
+ is a monomorphic operator. So is .. Perl values are polymorphic.
Arguing that operator-enforced coercions in Perl are implicit is silly nonsense; to do so you must assume a priori that values should be monomorphic.
I can write 1+$duration with no intention of doing a conversion.
You can also write $string + $duration with no intention of performing addition, but that has nothing to do with typing and everything to do with you writing buggy (or poorly understood) code.
| [reply] [d/l] [select] |
| [reply] |
| [reply] |