Re: Adding the ability to add functions into structures?



Chuck F. said:

> Jack Klein wrote:
>>
> ... snip ...
>>
>> I know I'll get flamed for this, but with the exception of
>> inheritance this is really nothing but syntactical sugar. You
>> can write object oriented programs in C right now.
>>
>> A perfect example is the FILE data type, declared an <stdio.h>.
>> It has a creator, fopen(), a destructor, fclose(), and all sorts
>> of methods you can invoke on it via its pointer, such as
>> fprintf(), fscanf(), fread(), fwrite(), between its successful
>> creation and its destruction.
>
> I see no reason for any fires. The only problem with your example
> is that you can't write (in general) that type in C.

I must have misunderstood what you mean, because I see no reason whatsoever
why one could not write (in general) that type in C.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
.



Relevant Pages

  • Re: UNIX, C, Perl
    ... because 'a' wouldn't be a simple pointer - it would need to be an ... so I think we're going to need a destructor of some kind. ... C is no exception. ...
    (comp.lang.c)
  • Re: Request to Ken (RE: Coding Standards)
    ... > destructor of the object will not be invoked, ... > coding guideline that prohibits you from dynamically allocating ... In the case of exceptional C++ constructors, the exact rule is the exception ... The second one has a related problem - what's a heap? ...
    (comp.object)
  • Re: is such exception handling approach good?
    ... No exception from this rule that I know of (no pun ... For the object pointed by smart pointer, ... Free that resource in the destructor. ... For resources other than the heap memory, you would use other classes to ...
    (microsoft.public.vc.language)
  • Re: Destructors are useless?
    ... > The really usefull information: who forgot to call Dispose, ... The specification says that, if a destructor throws, the exception ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Exception vs error handling
    ... "Fatal error: Exception thrown without a stack frame in Unknown on ... When I encountered it, PHP returned the ... variables aren't set to null) then its destructor is called at the ...
    (comp.lang.php)