3 ms·
Your link seems to argue that the simple fact that it's common convention makes it explicit, which doesn't really seem to hold water.
by gipp 9y ago
Your link seems to argue that the simple fact that it's common convention makes it explicit, which doesn't really seem to hold water.
- hoytech 9y agoConsider this javascript function: function add(a,b) { return a + b; } Although no conversion is requested explicitly in the function definition, a conversion may take place depending on the types of the arguments passed in: > add(1,2) 3 >add("1",2) "12" The article in question defines implicit conversion in this way, and in my experience it's a fairly common term. I was pointing out that per this definition, the article is wrong in saying that perl's + operator may perform an implicit conversion. In perl the + operator always performs a numeric conversion of both its operands, regardless of types. By writing + you are explicitly requesting numeric conversion of both arguments. In general perl doesn't perform implicit conversion (of course there are some exceptions -- it is perl after all). It does this by not overloading operators like + for different operations such as addition and concatenation. This also has the nice property that you can count on a+b == b+a, unlike python for instance. (However, in python PEP-465, non-commutativity was a stated advantage of adopting @ for matrix multiplication instead of overloading *, go figure).