473,804 Members | 3,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is a function an object?

Is a function an object?
Nov 14 '05 #1
14 1724
On Sun, 15 Aug 2004 18:02:17 -0700, "E. Robert Tisdale"
<E.************ **@jpl.nasa.gov > wrote:
Is a function an object?


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 intertranslatio ns to other frameworks should be easy enough
to propose.

And why might you ask?

J.

Nov 14 '05 #2
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > wrote:
Is a function an object?


"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.
Nov 14 '05 #3
On Sun, 15 Aug 2004 18:02:17 -0700, "E. Robert Tisdale"
<E.************ **@jpl.nasa.gov > wrote:
Is a function an object?


It depends! In languages like Python functions are objects in
their own right and can be queried for properties etc. Also in
several languages code blocks can be defined and treated aas
objects - Ruby, Lisp and Smalltalk are examples.

OTOH most OO practitioners equate functions with the methods of
an object rather than as first class objects in their own right.

HTH,

Alan G
Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld
Nov 14 '05 #4
I like Alan's explanation. He correctly prefaces it with, "It depends!"
Functions existing as objects themselves is a powerful concept that escapes
many programmers. It is worth investigating.
Nov 14 '05 #5
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > writes:
Is a function an object?


Warning: This question was cross-posted to comp.object and
comp.lang.c. (I'm reading it in comp.lang.c.)

In C terms, the answer is no, a function is not an object. We've just
had a rather tiresome thread on the subject. The C standard has a
reasonably precise definition of the term "object", and a function
clearly does not qualify. (Note that the C standard's definition of
"object" is not related to object-oriented programming; it's basically
just a region of data storage, such as a variable.)

Followups directed to comp.object.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #6
E. Robert Tisdale wrote:
Is a function an object?


Is a barnacle a ship?

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces
Nov 14 '05 #7
E. Robert Tisdale wrote:
Is a function an object?


Note that Tisdale is trolling by posting this question to two newsgroups
where the answer is different. I suppose he wants us to snip at each
other. In C, a function is not an object. Trollsdale is trying to get
the comp.object folk to tell the C folk that they are clueless. Please
don't oblige him. I have set the followups to news:comp.lang. c only,
since that's where I am. If folk on comp.object want to discuss this
question, I suggest they change the newsgroup or follow-up headers to
their newsgroup only.
Nov 14 '05 #8
Phlip wrote:
E. Robert Tisdale wrote:

Is a function an object?

Is a barnacle a ship?


Great album!

http://www.blackvelvet.be/barnacle-e.htm
Nov 14 '05 #9

"Thomas Gagne" <tg****@wide-open-west.com> wrote in message
news:Cb******** ************@wi deopenwest.com. ..
I like Alan's explanation. He correctly prefaces it with, "It depends!"
Functions existing as objects themselves is a powerful concept that escapes many programmers. It is worth investigating.


Whatever you call them, functions as those from C or many FPLs are not
objects. "Functions existing as objects" may be interesting to _think_ of
as functions (in the abstract), but are certainly not functions in the
traditional sense.

l8r, Mike N. Christoff

Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9604
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A, while an instance of class C should be able to check all methods #defined in C, B and A. #------------------------------------------------
7
1465
by: vegetax | last post by:
I i need a decorator that adds a local variable in the function it decorates, probably related with nested scopes, for example: def dec(func): def wrapper(obj = None): if not obj : obj = Obj() <bind obj to func> return func() return wrapper()
9
3700
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people discuss how reflection does this, but I cannot find the syntax to do this. I have tried several code example off of gotdotnet and other articles. Can somebody please show me the code to do this?
3
14958
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
2
7682
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would like mine to run immediately after it. So in the code below, what JS would i need to add to my "myfile.inc" page so that I could guarantee this behavior? <!-- main page --> <html> <head> <script type="text/javascript">
28
4341
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
5
2248
by: Daz | last post by:
Hi everyone. My query is very straight forward (I think). What's the difference between someFunc.blah = function(){ ; } and
4
2144
by: alex | last post by:
I am so confused with these three concept,who can explained it?thanks so much? e.g. var f= new Function("x", "y", "return x * y"); function f(x,y){ return x*y } var f=function(x,y){
7
3228
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the bastard so posting it before I forgot again... By taking this minimum code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head>
12
3022
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope. The global variables and global functions are hidden to prevent from accessing by the programmers. All global functions share global variables. Only very few global functions are allowed to be reusability for the programmers to use. Few...
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.