zoukankan      html  css  js  c++  java
  • 静态类型、动态类型、强类型以及弱类型语言

    弄清四个概念:


    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

  • 相关阅读:
    (转)Lucene.net搜索结果排序(单条件和多条件)
    .Net去html标签
    (转)Lucene.Net多字段查询,多索引查询
    HttpUtility
    内存卡问题汇总
    我的NHibernate
    (转)lucene.net和(pangu)盘古分词 搜索引擎的简单实现
    Power Designer使用技巧
    Oracle添加修改删除表字段
    在数据库开发过程中,数据库、表、字段、视图、存储过程等的命名规则
  • 原文地址:https://www.cnblogs.com/waniu/p/3269188.html
Copyright © 2011-2022 走看看