函数是一个对象吗? [英] Is a function an object?
问题描述
函数是对象吗?
Is a function an object?
推荐答案
On Sun,2004年8月15日18:02:17 -0700,E。 Robert Tisdale
< E. ************** @ jpl.nasa.gov>写道:
On Sun, 15 Aug 2004 18:02:17 -0700, "E. Robert Tisdale"
<E.**************@jpl.nasa.gov> wrote:
函数是一个对象吗?
通过OOP约定和一般含义,我会说不。我们将
函数等同于动词和对象到名词,并要求演员或轨迹
(名词)作为可执行函数(动词)的东西。
也就是说,将任何函数重新化为一个简单的
对象并不需要太多工作,除了该函数之外什么都不做,还有其他各种函数。 >
hacks和其他框架的互换应该很容易
建议。
你为什么要问?
J.
By OOP convention and general connotations, I''d say no. We equate
functions to verbs and objects to nouns, and demand an actor or locus
(noun) as a thing that can perform the function (verb).
That said, it doesn''t take much to reify any function into a trivial
object that does nothing but that function, and a variety of other
hacks and intertranslations to other frameworks should be easy enough
to propose.
And why might you ask?
J.
" E. Robert Tisdale <,E ************** @ jpl.nasa.gov>。写道:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote:
函数是一个对象吗?
"一个类可以被认为是一个C风格的函数它可以以线程安全的方式维护调用之间的状态,并且还可以提供多个服务的
。如果只有一个类的实例,并且
除了一个公共成员函数
之外的所有成员函数都被删除,结果将是一个C风格的函数(对象的'
成员数据将对应于
函数本地的静态数据。)" - Marshall Cline等。 __C ++ _ FAQs__ 2nd ed。
"A class can be thought of as a C-style function that can maintain state
between invocations in a thread-safe manner and can also provide
multiple services. If there were exactly one instance of a class, and
all its member functions except for exactly one public member function
were removed, the result would be a C-style function (the object''s
member data would correspond to static data that is local to the
function.)" -- Marshall Cline et al. __C++_FAQs__ 2nd ed.
On Sun,2004年8月15日18:02:17 -0700,E。 Robert Tisdale
< E. ************** @ jpl.nasa.gov>写道:
On Sun, 15 Aug 2004 18:02:17 -0700, "E. Robert Tisdale"
<E.**************@jpl.nasa.gov> wrote:
函数是一个对象吗?
这取决于!在像Python这样的语言中,函数是
中的对象,可以查询属性等。另外在
中,可以定义和处理几种语言的代码块。 >
对象 - Ruby,Lisp和Smalltalk就是例子。
OTOH大多数OO从业者将函数与
的方法等同于对象而不是本身就是一流的物品。
HTH,
Alan G
学习计划的作者网站
http://www.freenetpages.co.uk /hp/alan.gauld
这篇关于函数是一个对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!