Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is a function an object?

Reply
Thread Tools

Is a function an object?

 
 
E. Robert Tisdale
Guest
Posts: n/a
 
      08-16-2004
Is a function an object?
 
Reply With Quote
 
 
 
 
JXStern
Guest
Posts: n/a
 
      08-16-2004
On Sun, 15 Aug 2004 18:02:17 -0700, "E. Robert Tisdale"
<(E-Mail Removed)> 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 intertranslations to other frameworks should be easy enough
to propose.

And why might you ask?

J.

 
Reply With Quote
 
 
 
 
Daniel T.
Guest
Posts: n/a
 
      08-16-2004
"E. Robert Tisdale" <(E-Mail Removed)> 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.
 
Reply With Quote
 
Alan Gauld
Guest
Posts: n/a
 
      08-16-2004
On Sun, 15 Aug 2004 18:02:17 -0700, "E. Robert Tisdale"
<(E-Mail Removed)> 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
 
Reply With Quote
 
Thomas Gagne
Guest
Posts: n/a
 
      08-16-2004
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.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      08-16-2004
"E. Robert Tisdale" <(E-Mail Removed)> 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_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <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.
 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      08-16-2004
E. Robert Tisdale wrote:

> Is a function an object?


Is a barnacle a ship?

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      08-16-2004
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.
 
Reply With Quote
 
Michael N. Christoff
Guest
Posts: n/a
 
      08-16-2004

"Thomas Gagne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Fatted
Guest
Posts: n/a
 
      08-16-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function versus pointer to function, in context of std::function,huh? Alf P. Steinbach C++ 10 07-27-2011 05:51 AM
Function pointer to void function and int function Giannis Papadopoulos C Programming 5 09-05-2005 09:06 PM
How override ALL function calls? (Is there a "function call function"?) seberino@spawar.navy.mil Python 2 08-01-2005 12:38 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
Passing a C++ object's member function to a C function expecing a function pointer! James Vanns C++ 7 01-21-2004 02:39 AM



Advertisments