• 静态类型、动态类型、强类型以及弱类型语言


    弄清四个概念:


    1.静态类型定义语言     
      一种在编译时,数据类型是固定的语言。大多数静态类型定义语言强制这一点,它要求你在使用所有变量之前要声明它们的数据类型。Java和C是静态类型定义语言。     
        
    2.动态类型定义语言     
      一种在执行期间才去发现数据类型的语言,与静态类型定义相反。VBScript和Python是动态类型定义的,因为它们是在第一次给一个变量赋值的时候找出它的类型的。     
        
    3.强类型定义语言     
      一种总是强制类型定义的语言。Java和Python是强制类型定义的。如果你有一个整数,如果不显示地进行转换,你不能将其视为一个字符串 
        
    4.弱类型定义语言         
      一种类型可以被忽略的语言,与强类型定义相反。VBScript是弱类型定义的。在VBScript中,可以将字符串   '12'   和整数   3   进行连接得到字符串   '123',然后可以把它看成整数   123,而不需要显示转换。

    How Python's Datatypes Compare to Other Programming Languages 

    An erudite reader sent me this explanation of how Python compares to other programming languages: 
    statically typed language 
        A language in which types are fixed at compile time. Most statically typed languages enforce this by requiring you to declare all variables with their datatypes before using them. Java and C are statically typed languages. 
    dynamically typed language 
        A language in which types are discovered at execution time; the opposite of statically typed. VBScript and Python are dynamically typed, because they figure out what type a variable is when you first assign it a value. 
    strongly typed language 
        A language in which types are always enforced. Java and Python are strongly typed. If you have an integer, you can't treat it like a string without explicitly converting it. 
    weakly typed language 
        A language in which types may be ignored; the opposite of strongly typed. VBScript is weakly typed. In VBScript, you can concatenate the string '12' and the integer 3 to get the string '123', then treat that as the integer 123, all without any explicit conversion. 

    So Python is both dynamically typed (because it doesn't use explicit datatype declarations) and strongly typed (because once a variable has a datatype, it actually matters). 

    from 《Dive Into Python》, see: http://diveintopython.org/getting_to_know_python/declaring_functions.html

  • 相关阅读:
    SharePoint讨厌“+”吗?
    如何判断文件是否在占用?
    深入浅出SharePoint——设置站点的默认欢迎页面
    深入浅出SharePoint——通过Feature部署Webpart
    VS2008只支持jQuery1.4.1以下版本
    深入浅出SharePoint——Group的常用操作
    深入浅出SharePoint——更新计算列
    深入浅出SharePoint——计算列如何使用Item的ID
    深入浅出SharePoint——在VS2008中正确定义Webpart并通过feature来部署
    理解Javascript_10_对象模型
  • 原文地址:https://www.cnblogs.com/waniu/p/3269188.html
Copyright © 2020-2023  润新知