|
Post by tbird on Mar 28, 2023 14:57:03 GMT -6
I would like structs or types eventually in the future, although I'm used to doing everything arrays, the tiniest bit of oop is nice for encapsulation.
|
|
|
Post by n00b on Mar 28, 2023 15:42:21 GMT -6
I would like structs or types eventually in the future, although I'm used to doing everything arrays, the tiniest bit of oop is nice for encapsulation. I have been experimenting with it for a few years. If you look in the compiler source code you will find a lot of code for implementing custom user types but I never got any further than experimenting with it. I can try to put out some experimental builds to get some feedback on it. Since its such a huge feature, I would probably create a branch for that and maybe get it into 3.22 if it is stable by then.
|
|
|
Post by tbird on Mar 28, 2023 18:43:49 GMT -6
That would be epic, my cousin and I are talking about it, hes going through your videos and he keeps saying the array thing feels backwards, I am used to it. Although I do see the benefit in structs.
Absolutely no stress on this though its not a make or break thing.
|
|
|
Post by tbird on Mar 28, 2023 19:09:25 GMT -6
n00b, where is the code in the repo that corresponds to UDT's?
|
|
|
Post by n00b on Mar 29, 2023 1:21:24 GMT -6
n00b, where is the code in the repo that corresponds to UDT's? Look in identifier.h. There was also some parser code for it in parser.h at one point but it was all removed.
|
|
|
Post by rosy on Apr 6, 2023 5:18:27 GMT -6
What are these "types"
|
|
|
Post by tbird on Apr 6, 2023 12:38:53 GMT -6
rosy There is lots of info on the benefits of User Defined Types, although I believe its very subjective. I can give my reasons for liking them, but I would have to wait till I get home to write out a code example which I don't want to attempt on my phone, so will give my answer when I get home. Maybe n00b can chime in as well, but as his video shows they are definitely not required and using just arrays is very similar.
|
|
|
Post by rosy on Apr 8, 2023 2:53:45 GMT -6
What does this have to do with structures?
|
|
|
Post by tbird on Apr 8, 2023 7:59:52 GMT -6
Sorry rosy have been incredibly busy I was going to give an example will try today. To answer this question a UDT is a type of structure
|
|
|
Post by tbird on Apr 8, 2023 23:11:08 GMT -6
I tried to make an example...it sucks I haven't used types in a long time this is a poor example but an example nonetheless.
'TYPES
Type CollisionType Obstacle Damage Death EndType
Type Ent PosX PosY State$ Collision As CollisionType ID EndType
Player As Ent
Player.PosX = 100 Player.PosY = 250 Player.State$ = "Active" Player.Collision.Obstacle = 0 Player.Collision.Damage = 0 Player.Collision.Death = 0 Player.ID = 1
DIM Monsters[100] As Ent For i = 2 To 100 - 1 Monsters[i].PosX = 8 + (i*8) Monsters[i].PosY = 700 Monsters[i].State$ = "Active" Monsters[i].Collision.Obstacle = 0 Monsters[i].Collision.Damage = 0 Monsters[i].Collision.Death = 0 Monsters[i].ID = i Next
'ARRAYS
DIM EntPosX[100] DIM EntPosY[100] DIM EntState$[100] DIM EntCollisionObstacle[100] DIM EntCollisionDamage[100] 'These could be all just 1 array ex. DIM EntCollideType = 1, 2, Or 3 DIM EntCollisionDeath[100] 'but I'm trying to illustrate a point and this is what I came up with in my tired state DIM EntID[100]
DIM PlayerID : PlayerID = 1
EntPosX[PlayerID] = 100 EntPosY[PlayerID] = 250 EntState$[PlayerID] = "Active" EntCollisionObstacle[PlayerID] = 0 EntCollisionDamage[PlayerID] = 0 EntCollisionDeath[PlayerID] = 0 EntID[PlayerID] = 1
For i = 2 To 100 - 1 EntPosX[i] = 8 + (i + 8) EntPosY[i] = 700 EntState$[i] = "Active" EntCollisionObstacle[i] = 0 EntCollisionDamage[i] = 0 EntCollisionDeath[i] = 0 EntID[i] = i Next
Yup.
Completely not essential just alot cleaner and better readability to me anyway.
|
|
|
Post by rosy on Apr 9, 2023 4:45:30 GMT -6
That is, you need types AND structures. and you wrote "structs OR types"...
|
|
|
Post by aurel on Apr 9, 2023 7:12:52 GMT -6
Yo ... rosy TYPE is a STRUCTUREor in some languages called typeDef struct and is also UDT type myStructure dim a as INT dim b as STRINGend type dim c as myStructureso c is a UserDefinedType and as such can be myStructure.b = "rosy" myStructure.a = 1 infact this : c.b = "rosy" c.a = 1 but i think that you already know that ...i use UDT only when i must ..or is really hard to make something with arrays as containers aaahhhh i am so tiered and lazy today
|
|
|
Post by tbird on Apr 9, 2023 7:29:56 GMT -6
rosy As I previously stated and as aurel pointed out a udt is a structure. Some languages especially a couple basics use the term interchangeably. That is why I put OR.
|
|
|
Post by rosy on Apr 10, 2023 10:12:05 GMT -6
typedef char STRING[STRLEN+1];
STRING is a structure ?
And since you thought type=struct, you should have written type/struct, without Or.
|
|
|
Post by aurel on Apr 10, 2023 15:24:46 GMT -6
typedef char STRING[STRLEN+1]
do you think i am stupid
i wrote typedef struct ...not typedef char ..which is char array
|
|