🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sw.components
2 messages
2 total messages Started by Kyle Bernard Fri, 25 Aug 1989 16:12
OO programming by hand in C
#51
Author: Kyle Bernard
Date: Fri, 25 Aug 1989 16:12
35 lines
1683 bytes
There have been some recent mentions of object oriented programming 'by hand'
in C:

ted@nmsu.edu (Ted Dunning):

> ...
> the best example around is the X11 toolkit.  they do wonderful things
> with oo programming by hand in c. 
> ...

johnson@p.cs.uiuc.edu:

> ...
> However, he proves my point.  Calling a function stored in a structure
> IS run-time binding.  He is just showing how to do object-oriented
> programming in C.  It is fine to do object-oriented programming in
> C, and some people prefer that to using C++.  
> ...

I am interested in pointers to information (books, articles, etc.) concerning
this method of implementing objected oriented designs.  Our development
environment is very much C based and the migration to object based analysis
and design appears difficult enough without adding the problems of setting
up a new implementation environment.

Also, I am very interested in the experiences/impressions of those who are
currently using (or have used) C to implement objected oriented designs.

Thanks,
Kyle.
-- 
uucp:	    tektronix!tekfdi!honda!kyleb
US Mail:    Kyle Bernard, Microwave and RF Instruments, Tektronix, Inc.
	    Box 500  MS 58-072, Beaverton OR 97077
Phone:	    503-627-3522
Re: OO programming by hand in C
#59
Author: 3929
Date: Fri, 01 Sep 1989 18:23
54 lines
3059 bytes
In article <3363@tekfdi.FDI.TEK.COM> kyleb@tekfdi.FDI.TEK.COM (Kyle Bernard) writes:
>There have been some recent mentions of object oriented programming 'by hand'
>in C:
>
>I am interested in pointers to information (books, articles, etc.) concerning
>this method of implementing objected oriented designs.  Our development
>environment is very much C based and the migration to object based analysis
>and design appears difficult enough without adding the problems of setting
>up a new implementation environment.
>
>Also, I am very interested in the experiences/impressions of those who are
>currently using (or have used) C to implement objected oriented designs.
>
>Thanks,
>Kyle.

A couple of points:

1) It's fairly simple to get encapsulation by doing something like:

typedef struct _foo {
	...
	int	(*add)();
	...
} *FOO;

You can then invoke the 'add' function for a given 'object' by dereferencing
the pointer and calling the function.  This, I believe, is what was referred
to in a previous posting.  This is very nice and now that I've been using
encapsulation for a while I would never go back.  But personally I find that
inheritance is an even bigger plus, since it is what saves me typing (and
therefore mega-time, even though I am a fairly fast touch typist).


2) This is perhaps somewhat off the subject but...

I've recently implemented a somewhat brain-dead objects-a-la-Smalltalk front end
translator for C using 'nawk' (the new 'awk'), some shell scripts, and some
rather abusive uses of the C preprocessor and macros.  It is rather fragile (if
your input isn't just as the translator wants it to be, it throws a tantrum),
but other than that :) it is fairly nice.  If there is interest, I'd be
willing to discuss how this was done (then again, everyone has probably had
their fill of 'how I created my own OO extenstions to C' by now... :-).

Thanks,
--------------------------------------------------------------------------------
Brian R. Gilstrap    ...!{ {killer,bellcore}!texbell, uunet }!swbatl!uucibg
One Bell Center      +----------------------------------------------------------
Rm 17-G-4            | "Winnie-the-Pooh read the two notices very carefully,
St. Louis, MO 63101  | first from left to right, and afterwards, in case he had
(314) 235-3929       | missed some of it, from right to left."   -- A. A. Milne
--------------------------------------------------------------------------------
Disclaimer:
Me, speak for my company?  You must be joking.  I'm just speaking my mind.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads