[Gambas-user] Gambas 3 advancement
Benoît Minisini
gambas at ...1...
Tue Dec 21 03:26:06 CET 2010
> 2010/12/19 Benoît Minisini <gambas at ...1...>:
> > Tell me the important things I forgot, because I am sure I have forgotten
> > things.
> >
> > Not the small bugs, but the features that may change the language syntax
> > or the interface of some components.
>
> Hi Benoît. I think that a "mecanism" for automatic and selective
> sharing of public methods, properties and events from objects that are
> members of another, to it's container object, will be useful.
>
> Example. The ValueBox is compound for a TextBox, but the interface of
> TextBox isn't shared with ValueBox, nothing at all. If I want to share
> the complete interface of TextBox with ValueBox I should use
> inheritance, but there's no an automatic way to share partially and
> automatically the interface of TextBox to ValueBox because TextBox is
> a member of ValueBox (composition). So, this should be done manually,
> repeating the mayor part of interface of TextBox in ValueBox (there's
> no big deal in this case, but in others could be).
>
> Note: when a control is based on Control or UserControl through
> inheritance, some properties inherited (maybe methods too) have no
> sense in the new control, but inheritance have no way to anulate some
> members in the subclass, is all or nothing. In similar way composition
> or association forces to make public the member that "is part" or "is
> used", allowing access to it's complete interface (and, again, this
> many times haven't sense) or make it private, preventing access
> absolutely. (Containers are a special case that breaks the
> encapsulation through the collection "Children"). An new mecanism for
> selectively share part of interface of the an object for
>
> May be would be useful can do something like that:
>
> ' Inside ValueBox class
> shareInterface(TextBox, ValueBox, noneExcept, Name, X, Y, W, H, ...,
> Click, KeyPress, ... , Refresh, Resize, ...)
>
> shareInterface(TextBox, ValueBox, allExcept, Text, Password, ... )
>
> 'Syntax
> shareInterface(FromClass, ToClass, { allExcept | noneExcept } ,
> [properties] [events] [methods] )
>
>
> A name conceptually more accurate could be "Delegate"
>
> 'Syntax
> Delegate(ToClass, FromClass, { allExcept | noneExcept } , [properties]
> [events] [methods] )
>
>
>
> Good or crazy idea?
You can't "remove" something in inheritance, because if B inherits A, then B
is an A. So if the method m() (or a property) applies to A, it must applies to
B too.
Having to reimplement the interface in the composition case does not shock me.
If you really want inheritance, use inheritance.
But I admit it's a boring thing to write. Maybe a delegation mechanism could
be implemented, but not in Gambas 3 I think.
Note: delegation needs an object. For example, ValueBox will use its inner
TextBox as a delegate.
I'm currently implementing a Proxy class that allows to automatically delegate
events from one object to another one. But the result is not beautiful. I must
think about all that...
--
Benoît Minisini
More information about the User
mailing list