Types, reference errors, cloning?

Previous topic - Next topic

MrTAToad

Could always use C/C++ inline!

Schranz0r

Quote from: Slydog on 2015-Jan-08
I wish GLBasic had a reference type option.  This was a main reason I stopped using GLBasic.  I couldn't reference a Font type instance in a Label type instance, for example.  I had to use a FontId integer which became messy.

what you mean with this?!
inheritance or just a simple Con/Destructor?
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

kanonet

Quote from: TheMapChap on 2015-Jan-08
Could always use C/C++ inline!
Of cause once you have a pointer you can assign to it using INLINE C++, but there is no way that I know about, how you can add a pointer to a GLBasic TYPE. It would not be hard to change this, but ATM you could only work around it, if you write very big party of your program in INLINE - but if you write your program in INLINE, why should you use GLBasic in the 1st place?

@Schran0r: I think he simply means that he needs pointers, at least thats how I read this. But constructors/deconstructors are an other easy to add feature that I miss currently
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

bigsofty

#18
Glbasic creates a new instance(check out the produced C code) and then copies the values from the parent type, there is no need to clone in a function.

Also ALIAS can be used as a reference pointer, as long as you don't mind initialising it locally within each of your functions. I would really like to find a way of creating an ALIAS that can have the scope of a whole type though.

Btw, you can cast a GLB type int var as C pointer, in inline C, then set it, the pointer is then stored within the type. Using it, means uncasting it inline but as you said it not terrifically useful unless you really need to have that pointer bounces around with your type.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Slydog

Ya, I was referring to pointers.  I would have liked an option to reference a variable, not just copy the current value. 
This would be useful for TYPEs, as they would behave more OOPy / objecty. But also useful for non-OOP programming.
Now various TYPEs and their instances sit alone and you can only connect a member variable reference via an integer ID with a lookup into an array of instances.  Works, but feels kludgy.

Almost forgot about 'ALIAS', not really a replacement for pointers, but sure makes your code cleaner! Yes, make them available in TYPE definitions, then that would work.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Kitty Hello

The problem you mentioned does not exist. Code behaves as you expect it. Beware! Foreach and Alias create reference (i.e. pointer) variables that refer to garbage if the object pointed to gets removed or the array gets RESIZED!

Gesendet von meinem GT-N7100 mit Tapatalk