Re: Fwd: GTK+ is real object oriented?



Thanks to everybody.

You helped me to clarify the concepts of OO.


2009/12/20 David Nečas <yeti physics muni cz>:
> On Sun, Dec 20, 2009 at 05:26:20PM -0200, frederico schardong wrote:
>> Yes, C don't provide sintax support for do my example of method.
>>
>> In OOP such class must have self methods to set self attributes.
>>
>> What happen is GObject (by the C limitation) just have attributes, the
>> methods to set its attributes are functions out of the struct. Ok, is
>> this what happen, but for this facts don't broke the OOP?
>
> You have a weird definition of OO.
>
> Smalltalk people could tell you that calling methods is fake OO because
> to do real OO you must send messages to objects.  Now what?
>
> To the syntax issue.  In fact, virtual methods in Gtk+ are called
>
> GTK_WIDGET_GET_CLASS(widget)->show(widget)
>
> where GTK_WIDGET_GET_CLASS explicitly obtains the virtual table
> (referenced from within the object struct) because the compiler won't do
> it for you and then you can call the method.
>
> But as everyone else prefers a sane syntax to a cozy objectishy feeling,
> this is wrapped with something like gtk_widget_show() for virtual
> methods and non-virtual methods look entirely like functions.
>
> If it matters to you whether calling methods looks like
>
>    object.method(arg1, arg2)
>    object_method(arg1, arg2)
>    (object method arg1 arg2)
>    method { arg1 } { arg2 } : object
>
> then Gtk+ is fake OO by your definition but hardly anyone cares.
>
> If it matters to you in what bit of memory methods are physically
> stored, then check if Smalltalk, Ocaml, Haskel, etc. are OO according to
> your definition or not.  Hopefully you are aware the methods are seldom
> actually stored in `the object struct' even though they are placed there
> in the source code of e.g. C++ because that would be a collosal waste of
> resources.
>
> If you are troubled by the fact that one can write gtk_widget_frobnicate()
> that will look exactly like a GtkWidget method but would not be, then
> you simply noticed one of the things that cannot be enforced in C.  The
> rule is that you must not name functions gtk_widget_frobnicate().
>
> The object file compiled from gtkwidget.c then lists all the GtkWidget
> methods and is as good table of methods of the object as anything else.
>
> Yeti
>
>



-- 
Thanks,
Frederico Schardong,
SOLIS - Open source solutions
www.solis.coop.br
Linux registered user #500582


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]