Igor Tandetnik wrote:
> Chris Wolf <cw10...@gmail.com> wrote:
>   
>> It depends on your definition of "object".  I hate to nit-pick, but for
>> me, "object" may
>> contain data or code or both data and code.  So with this definition, C
>> implements objects
>> without code.
>>     
>
> Is there really a fundamental difference between
>
> struct X {
>   int data;
>   void DoSomething();
> };
> X x;
> x.DoSomething();
>
> and
>
> struct X {
>   int data;
> };
> void X_DoSomething(X* pThis);
> X x;
> X_DoSomething(&x);
>
> I bet both fragmens would produce nearly identical machine code. In this very 
> simple case, even syntactical sugar sprinkled over the first fragment doesn't 
> seem to make a huge difference. Of course, once you get into virtual 
> functions and multiple inheritance and so on, simulating equivalent behavior 
> in C gets progressively more unwieldly 

With GNU, you can investigate via "g++/gcc -O0 -no-dead-strip -S foo.c",
but unless you use the structure, the compiler won't
instantiate an instance even with -O0 and -no-dead-strip.   In any case,
even without virtual functions, at the machine code level,
there's still name mangling and calling convention differences.
> (but still possible: in fact, compilers exist that take C++ code and produce 
> equivalent C code).
>   
Yes, I dabbled with one called CFront from AT&T on Sun-3 back in the 80's.

   -Chris


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to