[Gambas-user] Request for advice
bb
adamnt42 at gmail.com
Mon Jul 12 20:28:29 CEST 2021
On Mon, 2021-07-12 at 12:25 -0500, John Dovey wrote:
>
>
> Some of the questions I have include:
> - does this make sense as a way to do this?
Yeah, it is "a" way.
> - What is the best way to store the returned collection? I thought
> about usingSTRUCT, but there is a prettyheavy warning in the wiki not
> to do so.
Let's get this STRUCT warning stuff sorted once and for all.
Structs were introduced to allow calls to and results from c++
libraries that packed stuff such that you couldn't access the innards
directly.
They are technically a word aligned memory area that is used by the
Gambas runtime interpreter to push and pull bits of that memory area in
and out of real Gambas variables. Conceptually they are a pseudo-class
with no methods and some public variables.
So unless you are putting together an interface to a lower level shared
library (let me say this quietly) THERE IS NO SANE REASON TO USE A
STRUCT WHEN A CLASS WILL DO.
Gambas is an object oriented language offering many (not all, personal
gripe omitted) OO features that guarantee lots of stuff like type
protection, inheritance , blah, blah, blah. So use the object-
orientation. Don't use stuff that is there for "getting around" the
protections to interact with languages that allow such BS. Gambas
classes use word alignment for data allocs, Structs don't.
Gambas variables are run length limited, structs aren't!!!!!!
Finally, structs may LOOK like a quick and easy way to set up a "data
structure" instead of the oh, maybe 12 seconds it takes to declare a
class.
> The BotMe info is in the attached image:
> JD
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
b
More information about the User
mailing list