静态打字 [英] Static typing

查看:56
本文介绍了静态打字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前是否有任何计划在未来推出静态类型

版本的Python? (我不完全确定静态打字是正确的

术语:我所说的是变量类型的声明,

参数和函数返回值)。


我知道有一个类型SIG这引入了几个提案,但是很久以前它已经过期了,我想知道是否已经就这个问题达成了一些共识,或者它是否已被搁置

无限期。


-

删除垃圾邮件和过滤组件以获取我的电子邮件地址。

解决方案

Michael Muller写道:

目前是否有任何计划在未来的任何版本中引入静态类型
版本Python?


AARGGHHHH!不!不要那样做!从来没有!!!!


(对不起,无法控制的神经反应......后来有3个安定......)


(我'我不完全确定静态类型是正确的术语:我所说的是变量类型的声明,
参数和函数返回值)。


这是正确的用语。这对于Python恕我直言也是错误的。

我知道有一个类型SIG介绍了几个提案,但它很久以前就已经过期了,我想知道是否就这个问题达成了一致意见




< flame-war-mode =''on''>

是的:

动态打字是好事(tm),

静态打字是邪恶(tm)! - )

< / flame-war-mode>

布鲁诺


Michael Muller写道:

目前是否有计划在未来的任何版本的Python中引入静态类型?




说真的,你为什么要这样做?


布鲁诺


Bruno Desthuilliers写道:

Michael Muller写道:

目前是否有计划在未来的任何版本的Python中引入静态类型?


说真的,你为什么这样做?



您_might_想要一些静态类型信息作为程序

文档或启用有效的程序转换。

类型sig有兴趣允许类型注释

。请记住,您可能想要的类型可能更像是

"这些对象必须具有哪些协议(通过

这个变量)遵循比这些物品的构造细节是什么




我希望看到界面描述描述什么

需要使用各种参数,并为我正在考虑使用的
包生成结果。如果有一个

中央蟒蛇认可的形式,那些描述甚至更好。

如果描述可以机械阅读,至少

有时会进行机械检查(可能很慢,可能只有

执行缓慢),我可能会使用这样的系统来检查模块

,然后再向全世界宣布。


一项非常古老的Sun研究确定,动态类型系统(smalltalk,IIRC)中的大多数变量几乎都是

of相同的类型。


David Ungar在优化中获得了相当多的里程数

a猜测了一种基于原型的驱动语言>
甚至不能用语言命名类型(你制造物品

就像那个除了......)。


我有一个关于如何使用基于行为的优化OODB的草图

打字。最大的诀窍是使用DB对数据库中的类

的知识(为数据库中的每个实例提供)来确定

。至少目前,给定

函数只有一种方法。这样的环境在查询优化方面可能比在任何允许您存储任意对象并根据消息调用检索它们的任何OODB更好地完成。/ br
。 />

-Scott David Daniels
Sc ****** *****@Acm.Org


Is there currently any plan to introduce static typing in any future
version of Python? (I''m not entirely sure that "static typing" is the right
term: what I''m talking about is the declaration of types for variables,
parameters and function return values).

I know there was a "types SIG" which introduced several proposals, but it
expired quite a while ago, and I was wondering whether whether some
consensus has been reached on the subject or if it has just been shelved
indefinitely.

--
Remove the spam and filter components to get my e-mail address.

解决方案

Michael Muller wrote:

Is there currently any plan to introduce static typing in any future
version of Python?
AARGGHHHH ! NO !! DON''T DO THAT !!! NEVER AGAIN !!!!

(sorry, uncontrolable nervous reaction... 3 valiums latter... : )

(I''m not entirely sure that "static typing" is the right term: what I''m talking about is the declaration of types for variables,
parameters and function return values).
This is the right term. This is also the wrong thing for Python IMHO.
I know there was a "types SIG" which introduced several proposals, but it
expired quite a while ago, and I was wondering whether whether some
consensus has been reached on the subject



<flame-war-mode=''on''>
Yes :
dynamic typing is good a Good Thing(tm),
static typing is Evil(tm) !-)
</flame-war-mode>
Bruno


Michael Muller wrote:

Is there currently any plan to introduce static typing in any future
version of Python?



Seriously, why would you do that ?

Bruno


Bruno Desthuilliers wrote:

Michael Muller wrote:

Is there currently any plan to introduce static typing in any future
version of Python?


Seriously, why would you do that ?



You _might_ want some static typing information as program
documentation or to enable efficient program translation. The
types sig was interested in allowing type annotation where
possible. Remember, the type you might want may be more like
"what protocol must these objects (the ones passing through
this variable) follow" than "what are the construction details
of these objects".

I would like to see interface descriptions describing what
kinds of parameters are required and results produced for
packages that I am considering using. If there were a single
central-python-endorsed form for those descriptions even better.
If the descriptions can be mechanically read, and at least
sometimes mechincally checked (possibly slowly, possibly only
for slow execution), I might use such a system to check a module
before announcing it to the world.

A very old Sun study determined that most variables in a
dynamically typed system (smalltalk, IIRC) are almost always
of the same type.

David Ungar got a fair amount of mileage out of optimizing for
a guessed common case in a protype-driven language where you
couldn''t even name types in the language (you make objects
"just like that one except...").

I had a sketch of how to optimize for OODBs using behavior-based
typing. The big trick was to use the DB''s knowledge of the classes
in the DB (provided for each instance in the DB) to determine
when there was, at least currently, only one method for the given
function. An environment like that might be able to do much
better at query optimization than any OODB that allows you to
store arbitrary objects and retrieve them based on message calls.

-Scott David Daniels
Sc***********@Acm.Org


这篇关于静态打字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆