[Gambas-user] how to write text in indexed list of labels
jussi.lahtinen at gmail.com
Mon Sep 7 23:18:54 CEST 2020
OK, so it is for performance reasons..? But if Me[xxx] would instead return
anonymous objects, shouldn't this again make the instances of label:
Dim hLabel as Label = Me[xxx]
And thus no performance differences? Or are the gained performance
differences somewhere else?
It seems I have misunderstood what exactly the Object.Type() returns... I
kind of expected Object.Scope().
Dim hParent As Parent = New Child
Dim hChild As New Child
Now they are a bit confusingly, both instances of Child class, just with
A little break from programming and object models are gone from my head.
On Mon, Sep 7, 2020 at 11:29 PM Benoît Minisini <g4mba5 at gmail.com> wrote:
> Le 07/09/2020 à 21:41, Jussi Lahtinen a écrit :
> > Look at it this way
> > Print TypeOf(Me["Label1"])
> > 16 (=gb.Object)
> > OK! It is an object so I can do Object "stuff" with it. Like looking
> > Object.Type
> > BUT if you read every word of the help for Object.Type
> > "Returns the class name of an object."
> > Object.Type(Me["Label1"]) is just rerturning a string which is the
> > of the class of which Me["Label1"] is an instance --- but it is
> > still an
> > object not a Label!
> > I don't understand your point. That is exactly what I expect to see.
> > TypeOf returns "object" for every possible instance of every possible
> > So, instance of Label is object and TypeOf will return so as expected.
> > The problem is that Me["Label1"] does not return an object, which is an
> > instance of class label, but instance of class control.
> > That is unexpected. Looks like a bug to me.
> > Jussi
> No, it's by design. ME[xxx] can return any subclass of the Control
> class, so it's logical that its datatype is Control.
> If you know that ME[xxx] is a Label, then you have to store it into a
> variable declared as Label. Otherwise you can't access the Label class
> properties or methods.
> Remember that the Object datatype is "anonymous". Each access to a
> property or a method through the Object datatype needs a search into the
> symbol table at each access, which is slow.
> As soon as the interpreter gets an actual datatype (like Control for
> Form[xxx]), then the symbol table search is done once, and every
> following access is immediate, which is fast.
> Benoît Minisini
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User