ill几个hi了是起死回生的爱

公共英语--PETS三级词汇(组)_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
喜欢此文档的还喜欢
公共英语--PETS三级词汇(组)
公​共​英​语​三​词​组
阅读已结束,如果下载本文需要使用
想免费下载本文?
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢弱类型、强类型、动态类型、静态类型语言的区别是什么?
最好能列举以下各类型的主要语言
按投票排序
类型系统的一些概念,众说纷纭,使用上也比较乱。有些东西,甚至不好严格定义。以下算学术界的一种相对“严格”的说法。1.
先定义一些基础概念Program Errorstrapped errors。导致程序终止执行,如除0,Java中数组越界访问untrapped errors。 出错后继续执行,但可能出现任意行为。如C里的缓冲区溢出、Jump到错误地址Forbidden Behaviours
语言设计时,可以定义一组forbidden behaviors. 它必须包括所有untrapped errors, 但可能包含trapped errors.Well behaved、ill behavedwell behaved: 如果程序执行不可能出现forbidden behaviors, 则为well behaved。ill behaved: 否则为ill behaved...2. 有了上面的概念,再讨论强、弱类型,静态、动态类型强、弱类型强类型strongly typed: 如果一种语言的所有程序都是well behaved——即不可能出现forbidden behaviors,则该语言为strongly typed。弱类型weakly typed: 否则为weakly typed。比如C语言的缓冲区溢出,属于trapped errors,即属于forbidden behaviors..故C是弱类型前面的人也说了,弱类型语言,类型检查更不严格,如偏向于容忍隐式类型转换。譬如说C语言的int可以变成double。 这样的结果是:容易产生forbidden behaviours,所以是弱类型的动态、静态类型静态类型 statically: 如果在编译时拒绝ill behaved程序,则是动态类型dynamiclly: 如果在运行时拒绝ill behaviors, 则是dynamiclly typed。3. 误区大家觉得C语言要写int a, int b之类的,Python不用写(可以直接写a, b),所以C是静态,Python是动态。这么理解是不够准确的。譬如Ocaml是静态类型的,但是也可以不用明确地写出来。。Ocaml是静态隐式类型静态类型可以分为两种:如果类型是语言语法的一部分,在是explicitly typed显式类型;如果类型通过编译时推导,是implicity typed隐式类型, 比如ML和Haskell4.下面是些例子无类型: 汇编弱类型、静态类型 : C/C++弱类型、动态类型检查: Perl/PHP强类型、静态类型检查 :Java/C#强类型、动态类型检查 :Python, Scheme静态显式类型 :Java/C静态隐式类型 :Ocaml, Haskell
给的定义比较详细,但我觉得并不易于理解,而且我看到评论里已经有人产生了一些误解。我的理解是,这些概念本身就只是一种通俗的说法,并没有严格的定义,只能勉强用一些术语来厘清边界。下面是里给的一种解释,我觉得更易于理解:从图上看,静态类型、动态类型大家应该明白其实是指的Type Check发生的时机。而强类型、弱类型到底是什么意思呢?其实这些词语本身概念就是模糊不清的,反正我是能避免使用就尽量避免使用。从图上看,静态类型、动态类型大家应该明白其实是指的Type Check发生的时机。而强类型、弱类型到底是什么意思呢?其实这些词语本身概念就是模糊不清的,反正我是能避免使用就尽量避免使用。So what is “strong typing”?This appears to be a meaningless phrase, and people often use it in a non-sensical fashion. To some it seems to mean “The language has a type checker”. To others it means “The language is sound” (that is, the type checker and run-time system are related). To most, it seems to just
mean, “A language like Pascal, C or Java, related in a way I can’t quite make precise”. If someone uses this
phrase, be sure to ask them to define it for you. (For amusement, watch them squirm.) 在
的回答下面提了一个疑问,我理了一下这个逻辑:按照定义,如果在编译时拒绝ill behaved程序,则是statically typed。按照定义,如果一种语言的所有程序都是well behaved,则该语言为strongly typed。那么,所有statically typed语言都是well behaved,即strongly typed。这逻辑错在哪里呢?问题在于:在编译时拒绝(部分)ill behaved是编译器的行为,并不是概念上的定义。事实上,问题正出在 「Statically Typed」这个词身上!可以这么说,并不存在 Statically Typed,只有 Statically Checked。因为它不是语言固有属性,而是编译器的行为,搞清这点就不会产生误解了。可能有人会问,既然Statically Typed 不是语言固有属性,那C\C++、Java的类型声明又怎么解释呢?前面说了,那叫「Explicitly Typed」,类型是语言语法的一部分,但到底是静态检查还是运行期检查,或者是根本不检查,那就是编译器解释器的行为了。比如PHP有Type Hint,看上去就像 Explicitly Typed,但它是运行到那行代码才检查,仍然不是Statically Checked。好了,现在静态类型动态类型算是搞清楚了吧。那 Type Safety 呢?Type safety is the property that no primitive operation ever applies to values of the wrong type. By primitive operation we mean not only addition and so forth, but also procedure application. A safe language honors the abstraction boundaries it erects.这也算是通俗的解释了,符合大众印象,大家所理解的强类型、类型安全等,通常都是指运算符和函数调用,比如将原本作用于Int的“*”去用到字符串上是不合法的。为什么C/C++ 是Type unsafe呢?注意,type是和value绑定到一起的,所以:int a = 4;
char* s = (char*)a; //假设类型转换OK通过编译
void f(char* s);
f(s); // unsafe
C/C++ 本不具备一个 Sound Type Systems,即它的类型系统本身就并不能保证安全。为什么大家认为Python是强类型呢?也就是说他们倾向于认为Python是类型安全的?CPython解释器就是Python语言事实上的标准,所以我们就直接看Python解释器的行为了,它会在运行期检测类型错误:class A:
def halo(self):
A.halo(B()) # 抛出 TypeError,如果B继承自A则不会报错
当然,ctypes这种东西我们就不考虑了。相比之下,JavaScript就很明显谈不上类型安全。
强类型:偏向于不容忍隐式类型转换。譬如说haskell的int就不能变成double弱类型:偏向于容忍隐式类型转换。譬如说C语言的int可以变成double静态类型:编译的时候就知道每一个变量的类型,因为类型错误而不能做的事情是语法错误。动态类型:编译的时候不知道每一个变量的类型,因为类型错误而不能做的事情是运行时错误。譬如说你不能对一个数字a写a[10]当数组用。
前两者,弱/强类型指的是语言类型系统的类型检查的严格程度。后两者指的是变量与类型的绑定方法。
弱类型相对于强类型来说类型检查更不严格,比如说允许变量类型的隐式转换,允许强制类型转换等等。强类型语言一般不允许这么做。这篇wiki上有例子:
静态类型指的是编译器在compile time执行类型检查,动态类型指的是编译器(虚拟机)在runtime执行类型检查。简单地说,在声明了一个变量之后,不能改变它的类型的语言,是静态语言;能够随时改变它的类型的语言,是动态语言。因为动态语言的特性,一般需要运行时虚拟机支持。附伟大的Wiki有完全的类型系统对比表格,请参见:
长了点,希望能耐心看完。看过不同的文章后,整理出来的中文解释(底下有英文解释):==============================动态语言vs静态语言(动态类型语言vs静态类型语言)Static typing when possible, dynamic typing when needed型态系统(type system):程序中专门处理数据的系统。语言可以分为动态型态系统(dynamically typed systems),例如Lisp,JavaScript,Tcl和Prolog静态型态系统(statically typed systems),例如C++和Java静态型态系统可进一步分为包含宣告型态(manifest type)语言,即每一个变量和函数的型态都清楚地宣告type-inferred语言(例如MUMPS,ML)==============================动态类型语言(Dynamically Typed Language):运行期间才做数据类型检查的语言,即动态类型语言编程时,永远不用给任何变量指定数据类型。该语言会在第一次赋值给变量时,在内部将数据类型记录下来。例如:ECMAScript(JavaScript)、Ruby、Python、VBScript、phpPython和Ruby就是典型动态类型语言,其他各种脚本语言如VBScript也多少属于动态类型语言优点:方便阅读,不需要写非常多的类型相关的代码;缺点:不方便调试,命名不规范时会造成读不懂,不利于理解等静态类型语言(Statically Typed Language):编译期间做检查数据类型的语言,即写程序时要声明所有变量的数据类型,是固定的。使用数据之前,必须先声明数据类型(int ,float,double等)。相当于使用之前,首先要为它们分配好内存空间。例如:C/C++是静态类型语言的典型代表,其他的静态类型语言还有C#、JAVA等优点:结构非常规范,便于调试,方便类型安全缺点:为此需要写更多类型相关代码,不便于阅读、不清晰明了强类型定义语言(Explicit type conversion,强制数据类型定义语言,类型安全的语言):一旦变量被指定某个数据类型,如果不经强制转换,即永远是此数据类型。举例:若定义了一个整型变量a,若不进行显示转换,不能将a当作字符串类型处理强类型语言是指需要进行变量/对象类型声明的语言,一般情况下需要编译执行。例如C/C++/Java/C#弱类型定义语言(Implicit type conversion,类型不安全的语言):数据类型可以被忽略的语言。它与强类型定义语言相反, 一个变量可以赋不同数据类型的值。举例:在VBScript中,可以将字符串 '12' 和整数 3 进行连接得到字符串 '123',
然后可以把它看成整数 123,而不需要显示转换例如PHP/ASP/Ruby/Python/Perl/ABAP/SQL/JavaScript/Unix Shell等注意:强类型定义语言在速度上可能略逊色于弱类型定义语言,但是强类型定义语言带来的严谨性能够有效的避免许多错误。==============================“语言是否动态”与“语言是否类型安全”之间是完全没有联系的!Python是动态语言,是强类型定义语言(类型安全的语言); VBScript是动态语言,是弱类型定义语言(类型不安全的语言); JAVA是静态语言,是强类型定义语言(类型安全的语言)==============================In computer science, type conversion, typecasting, and coercion are different ways of, implicitly or explicitly, changing an entity of one data type into another. ==============================英文解释 (from 《Dive Into Python》)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 discover 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. Explicit 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. Implicit typed language
A language in which
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. 关于Python的类型: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).
动态类型语言:在运行期进行类型检查的语言,也就是在编写代码的时候可以不指定变量的数据类型,比如Python和Ruby静态类型语言:它的数据类型是在编译期进行检查的,也就是说变量在使用前要声明变量的数据类型,这样的好处是把类型检查放在编译期,提前检查可能出现的类型错误,典型代表C/C++和Java强类型语言,一个变量不经过强制转换,它永远是这个数据类型,不允许隐式的类型转换。举个例子:如果你定义了一个double类型变量a,那么程序不可能将a当作int类型处理。典型代表是Java。弱类型语言:它与强类型语言定义相反,允许编译器进行隐式的类型转换,典型代表C/C++。
类型这块东西内容是很丰富的,如果楼主真要本质的理解类型在程序语言中的作用,推荐看皮尔斯的《Types and programming languages》从最原始的Untyped system,到简单的type system,然后衍生出subtype system,recursive type system,polymorphism type system,higher order type system。从中你可以看到不同于图灵机的基于lambda的计算模型(源于图灵的老师Church)是怎样一步步构建类型系统的,你也可以学到即便是动态类型,也能静态的推导出其类型,如Standard ML语言。总之,这个领域内容很丰富,不是简单的一页wiki就能解释清楚的。
我来很不负责任地把我编程语言课上的笔记贴上来吧作者:Todd Millstein, Ph. D.(* Types
what is a value?
- any legal result of a program (expression)
what is a type?
- a set of values that have a shared set of operations
example: int is the set of 32-bit integers
operations: +, -, *, &, etc.
values: [], [1;2;3]
operations:
int * bool
values: (1, true)
operations: access components (by pattern matching)
int -& bool
values: (function x -& x&3)
operations: call the function
Two dimensions on which to evaluate type systems:
1. Static vs. dynamic typechecking
- static means "at compile time"
- before execution
- give each expression E in the program a type T
- guarantee: if E has type T then at run time the value of E (if
E's evaluation terminates normally)will be a member of the set
advantages:
- catch errors early
- checking all possible executions of a function
- faster at run time
- no need to re-check types at run time
- allows some compiler optimizations
- program documentation
disadvantages:
- restrictive (conservative)
- can reject your program even if it's not buggy
example: heterogenous lists
# [1; "hi"; 34; "bye"];;
Error: This expression has type string but an expression was expected of type
how to achieve the same behavior?
1. a list of pairs
# [(1,"hi"); (34, "bye")];;
- : (int * string) list = [(1, "hi"); (34, "bye")]
2. use a datatype
# type intorstring = I of int | S;
type intorstring = I of int | S of string
# [I 1; S "hi"; S "bye"; I 34];;
- : intorstring list = [I 1; S "hi"; S "bye"; I 34]
- slower compilation dynamic typechecking:
just run the code
before *every* primitive operation
- check that the operation is being passed
values of the right type key benefit of static typechecking:
gives a strong guarantee for *all* possible executions of a function
e.g., consider a function of type int-&bool
- we know that no matter what integer we pass in, we will get back a boolean
- and will not have any type errors during evaluation
- (but the execution may not terminate, or may have a run-time exception -- the type system doesn't prevent those things)
in a dynamically typed language, even if 500 calls to a function did the right thing, there's no guarantee that the
501st call won't crash with a type error due to a bug, e.g. attempting to invoke + on an int and a string.2. Strong vs. weak typechecking
- strongly typed means the language never allows an operation
to be invoked with operands of the wrong type
- never allows undefined behavior
- weakly typed means you can get into an undefined state
(and keep executing)
the only weakly typed languages are C and C++
- the language just assumes that e has type int
- weakly typed languages are not memory safe
- a memory safe language is one that only allows
the program to access memory that it allocated
violations:
- access elements of an array out of bounds
- treat an int as a pointer
- dangling pointers
how do strongly typed languages deal with these issues?
- runtime checks (array bounds)
- hide the pointers
- garbage collection
strong/static: Java, OCaml
strong/dynamic: Python, PHP, Javascript, Lisp, Smalltalk
weak/static:
weak/dynamic:
贴上,里面讲的比较详细补全对话; (共5分,每空1分)在对话空白处填上适当的话语(话语可以是句子、短语或词),使对话完整、正确。(D---Dick, J---John)D: Hello! May I ____【小题1】____John, please?J: This is John speaking. ____【小题2】____?D: It’s Dick.J: Hi, Dick. Where are you?D: I’m at home and looking after my mother.J: ____【小题3】____?D: She’s ill. She has caught a bad cold.J: ____【小题4】____. Can I help you?D: Yes, thank you. I hear a New English-Chinese Dictionary is on sale.Would you mind going there and getting one for me?J: I’ll be ____【小题5】____ to. I’ll go right now.D: Thank you very much. Bye-bye.J: Bye-bye.-乐乐题库
& Unite知识点 & “补全对话; (共5分,每空1分)在对话空...”习题详情
288位同学学习过此题,做题成功率68.7%
补全对话; (共5分,每空1分)在对话空白处填上适当的话语(话语可以是句子、短语或词),使对话完整、正确。(D---Dick, J---John)D: Hello! May I &&&&【小题1】&&&&John, please?J: This is John speaking. &&&&【小题2】&&&&?D: It’s Dick.J: Hi, Dick. Where are you?D: I’m at home and looking after my mother.J: &&&&【小题3】&&&&?D: She’s ill. She has caught a bad cold.J: &&&&【小题4】&&&&. Can I help you?D: Yes, thank you. I hear a New English-Chinese Dictionary is on sale.Would you mind going there and getting one for me?J: I’ll be &&&&【小题5】&&&& to. I’ll go right now.D: Thank you very much. Bye-bye.J: Bye-bye.speak to&
本题难度:一般
题型:解答题&|&来源:2014-辽宁省丹东市第六中学九年级第二次模拟英语试卷
分析与解答
习题“补全对话; (共5分,每空1分)在对话空白处填上适当的话语(话语可以是句子、短语或词),使对话完整、正确。(D---Dick, J---John)D: Hello! May I ____【小题1】____Joh...”的分析与解答如下所示:
【小题1】我可以找约翰听电话吗?根据句意,故填speak to【小题2】在英语中电话中问对方是谁,应该用that指代对方,故填Who’s that【小题3】根据后文回答她病了,可知上句在问她怎么了。故填What’s wrong with her【小题4】听到不幸的消息,首先表示遗憾,故填I’m sorry to hear that.【小题5】根据上句的请求,和后文的回答I’ll go right now ,可知乐意去,故填glad
找到答案了,赞一个
如发现试题中存在任何错误,请及时纠错告诉我们,谢谢你的支持!
补全对话; (共5分,每空1分)在对话空白处填上适当的话语(话语可以是句子、短语或词),使对话完整、正确。(D---Dick, J---John)D: Hello! May I ____【小题1】__...
错误类型:
习题内容残缺不全
习题有文字标点错误
习题内容结构混乱
习题对应知识点不正确
分析解答残缺不全
分析解答有文字标点错误
分析解答结构混乱
习题类型错误
错误详情:
我的名号(最多30个字):
看完解答,记得给个难度评级哦!
还有不懂的地方?快去向名师提问吧!
与“补全对话; (共5分,每空1分)在对话空白处填上适当的话语(话语可以是句子、短语或词),使对话完整、正确。(D---Dick, J---John)D: Hello! May I ____【小题1】____Joh...”相似的题目:
Mary likes drinking milk&&&& honey every morning.andwithinhas
Life is full of &&&& wonders, but they’re not always &&&& ones we hope for./; the the/; / /
根据对话内容,从方框内的选项中选出横线上所需的选项(选项中有两项多余选项),并在答题卡上相应的位置按要求填涂。John: Oh, Tom. Please don’t sit on the chair!Tom:. 【小题1】&&&&John: Look! One of its legs is broken. It’s dangerous to sit on it Tom: 【小题2】&&&&&Who’s broken it?John: I don’t know. I found it when I was cleaning the floor. Tom: Let’s tell our teacher about it and then someone can repair it.John: No. 【小题3】&&&&Tom:. Yourself? Have you learnt to repair a chair?John: Yes. My father is a worker. He is good at repairing things. 【小题4】&&&&Tom: Oh, your father taught you.【小题5】John:. Certainly. Let’s begin.A. Hurry up!B. What’s the
matter?C. Thank you for
telling me about it.D. I think I can
repair it myself.E. That’s a good
idea.F. He taught me
how to do that.G. Shall we do it
together?&&&&
“补全对话; (共5分,每空1分)在对话空...”的最新评论
该知识点好题
该知识点易错题
欢迎来到乐乐题库,查看习题“补全对话; (共5分,每空1分)在对话空白处填上适当的话语(话语可以是句子、短语或词),使对话完整、正确。(D---Dick, J---John)D: Hello! May I ____【小题1】____John, please?J: This is John speaking. ____【小题2】____?D: It’s Dick.J: Hi, Dick. Where are you?D: I’m at home and looking after my mother.J: ____【小题3】____?D: She’s ill. She has caught a bad cold.J: ____【小题4】____. Can I help you?D: Yes, thank you. I hear a New English-Chinese Dictionary is on sale.Would you mind going there and getting one for me?J: I’ll be ____【小题5】____ to. I’ll go right now.D: Thank you very much. Bye-bye.J: Bye-bye.”的答案、考点梳理,并查找与习题“补全对话; (共5分,每空1分)在对话空白处填上适当的话语(话语可以是句子、短语或词),使对话完整、正确。(D---Dick, J---John)D: Hello! May I ____【小题1】____John, please?J: This is John speaking. ____【小题2】____?D: It’s Dick.J: Hi, Dick. Where are you?D: I’m at home and looking after my mother.J: ____【小题3】____?D: She’s ill. She has caught a bad cold.J: ____【小题4】____. Can I help you?D: Yes, thank you. I hear a New English-Chinese Dictionary is on sale.Would you mind going there and getting one for me?J: I’ll be ____【小题5】____ to. I’ll go right now.D: Thank you very much. Bye-bye.J: Bye-bye.”相似的习题。公共英语三级词组_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
评价文档:
喜欢此文档的还喜欢
公共英语三级词组
公​共​英​语​三​级​词​组
阅读已结束,如果下载本文需要使用
想免费下载本文?
把文档贴到Blog、BBS或个人站等:
普通尺寸(450*500pix)
较大尺寸(630*500pix)
你可能喜欢

我要回帖

更多关于 梦幻西游手游起死回生 的文章

 

随机推荐