[Gambas-user] Re: a few suggestions for improvement
Christian Faure
christian.faurebouvard at ...357...
Thu Jan 6 11:30:00 CET 2005
Hello,
Just somes workarounds:
> > I already mentioned the lack of casting Operators.
> > Take for example another code from my current work (stripped down):
> > DIM control AS Control
> >
> > SELECT CASE type
> > CASE "select"
> > control=NEW ComboBox(detailFrame) AS "EditControls"
> > Object.SetProperty(control, "ReadOnly", TRUE)
> > END SELECT
> >
> > this factory creates a control depending upon a parameter.
> > It has to set a few parameters, like ReadOnly=TRUE
> > It would be nice if I could write:
> > ((ComboBox)control).ReadOnly=TRUE
> > or
> > Cast(ComboBox, control).ReadOnly = TRUE
> > or something like that.
Try declare control as Object:
DIM control AS Object
SELECT CASE type
CASE "select"
control=NEW ComboBox(detailFrame) AS "EditControls"
control.ReadOnly=TRUE
END SELECT
> > Why doesn't gambas do virtual dispatching?
> > I have a base class called Base and a derived class called Derived.
> > bot implement the method GetQuery()
> >
> > When I have a reference to Base (which really is a reference to Derived,
> > but was upcast)
> > and call GetQuery() it will call Base's GetQuery instead of Derived's
> > one.
> >
> > I have to use
> > Object.Call(obj, "GetQuery")
> > but this isn't so nice.
> >
> > So I worked around it by implementing GetQuery only in Base which looks
> > like:
> > public function GetQuery() as Foo
> > return Object.Call(ME, "doGetQuery")
> > end
> >
> > Derived and Base implement also doGetQuery which does the actual work.
> > But the drawback is: doGetQuery can't be private, because Object.Call
> > wouldn't have access to it...
> >
> > I would like to see virtual dispatching in gambas improved, because
> > currently it is (IMHO) a mess.
Same as above: declare your reference as Object
dim Base as Object
dim Derived as Object
Base=new("Base")
Derived=new("Derived")
so, Derived.GetQuery() call Derived.GetQuery()
if GetQuery not defined in Derived, then
Derived.GetQuery() call Base.GetQuery()
Regards,
Christian
More information about the User
mailing list