weak-typing

Does it make sense to use Hungarian notation prefixes in interpreted languages? [closed]

Deadly 提交于 2019-11-30 07:07:11
First of all, I have taken a look at the following posts to avoid duplicate question. https://stackoverflow.com/questions/1184717/hungarian-notation Why shouldn't I use "Hungarian Notation"? Are variable prefixes (“Hungarian notation”) really necessary anymore? Do people use the Hungarian Naming Conventions in the real world? Now, all of these posts are related to C#, C++, Java - strongly typed languages. I do understand that there is no need for the prefixes when the type is known before compilation. Nevertheless, my question is: Is it worthwhile to use the prefixes in interpreter based

Static/strong typing and refactoring

独自空忆成欢 提交于 2019-11-30 04:56:39
问题 It seems to me that the most invaluable thing about a static/strongly-typed programming language is that it helps refactoring: if/when you change any API, then the compiler will tell you what that change has broken. I can imagine writing code in a runtime/weakly-typed language ... but I can't imagine refactoring without the compiler's help, and I can't imagine writing tens of thousands of lines of code without refactoring. Is this true? 回答1: I think you're conflating when types are checked

Does it make sense to use Hungarian notation prefixes in interpreted languages? [closed]

╄→гoц情女王★ 提交于 2019-11-29 09:26:34
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . First of all, I have taken a look at the following posts to avoid duplicate question. https://stackoverflow.com/questions/1184717

Does ruby 1.9.2 have an is_a? function?

孤者浪人 提交于 2019-11-29 05:17:56
I googled that there is an is_a? function to check whether an object is an integer or not. But I tried in rails console, and it doesn't work. I ran the code like the following: "1".is_a? 1.is_a? Did I miss something? There's not a built in function to say if a string is effectively an integer, but you can easily make your own: class String def int Integer(self) rescue nil end end This works because the Kernel method Integer() throws an error if the string can't be converted to an integer, and the inline rescue nil turns that error into a nil. Integer("1") -> 1 Integer("1x") -> nil Integer("x")

Is Python a weakly typed language as variables can switch types?

回眸只為那壹抹淺笑 提交于 2019-11-28 20:51:30
The way I understand it, the following is allowed in PHP because it's a weakly-typed language. $var = 'Hello'; $var = 5; I just installed a Windows version of Python 2.6 and I was expecting it NOT to let me change type just like that, but the Python equivalent of the above code works just like in PHP yikes! >>> var = "Hello" >>> type(var) <type 'str'> >>> var = 5 >>> type(var) <type 'int'> Is my understanding of weak/strong typing flawed? Your example demonstrates dynamic typing, not weak typing. Dynamic typing generally means that the type of data an object can store is mutable; any target

Can someone tell me what Strong typing and weak typing means and which one is better?

瘦欲@ 提交于 2019-11-28 17:12:42
Can someone tell me what Strong typing and weak typing means and which one is better? That'll be the theory answers taken care of, but the practice side seems to have been neglected... Strong-typing means that you can't use one type of variable where another is expected (or have restrictions to doing so). Weak-typing means you can mix different types. In PHP for example, you can mix numbers and strings and PHP won't complain because it is a weakly-typed language. $message = "You are visitor number ".$count; If it was strongly typed, you'd have to convert $count from an integer to a string,

Does ruby 1.9.2 have an is_a? function?

前提是你 提交于 2019-11-27 22:47:59
问题 I googled that there is an is_a? function to check whether an object is an integer or not. But I tried in rails console, and it doesn't work. I ran the code like the following: "1".is_a? 1.is_a? Did I miss something? 回答1: There's not a built in function to say if a string is effectively an integer, but you can easily make your own: class String def int Integer(self) rescue nil end end This works because the Kernel method Integer() throws an error if the string can't be converted to an integer

Is Python a weakly typed language as variables can switch types?

对着背影说爱祢 提交于 2019-11-27 13:12:48
问题 The way I understand it, the following is allowed in PHP because it's a weakly-typed language. $var = 'Hello'; $var = 5; I just installed a Windows version of Python 2.6 and I was expecting it NOT to let me change type just like that, but the Python equivalent of the above code works just like in PHP yikes! >>> var = "Hello" >>> type(var) <type 'str'> >>> var = 5 >>> type(var) <type 'int'> Is my understanding of weak/strong typing flawed? 回答1: Your example demonstrates dynamic typing, not

Can someone tell me what Strong typing and weak typing means and which one is better?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 10:16:37
问题 Can someone tell me what Strong typing and weak typing means and which one is better? 回答1: That'll be the theory answers taken care of, but the practice side seems to have been neglected... Strong-typing means that you can't use one type of variable where another is expected (or have restrictions to doing so). Weak-typing means you can mix different types. In PHP for example, you can mix numbers and strings and PHP won't complain because it is a weakly-typed language. $message = "You are

Is C++ considered weakly typed? Why?

混江龙づ霸主 提交于 2019-11-27 03:14:54
问题 I've always considered C++ to be one of the most strongly typed languages out there. So I was quite shocked to see Table 3 of this paper state that C++ is weakly typed. Apparently, C and C++ are considered weakly typed since, due to type-casting, one can interpret a field of a structure that was an integer as a pointer. Is the existence of type casting all that matters? Does the explicit-ness of such casts not matter? More generally, is it really generally accepted that C++ is weakly typed?