Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Declaring Functions AS TYPEs
#1
So many times I have wished for this:

TYPE TYPE_VECTOR
    x AS SINGLE
    y AS SINGLE
END TYPE

FUNCTION AddVector(v1 AS TYPE_VECTOR, v2 AS TYPE_VECTOR) AS TYPE_VECTOR
    AddVector.x = v1.x + v2.x
    AddVector.y = v1.y + v2.y
END FUNCTION

Or even this would be awesome

DIM v1 AS TYPE_VECTOR
DIM v2 AS TYPE_VECTOR
DIM v3 AS TYPE_VECTOR

v1.x = 10: v1.y = 20
v2.x = 15: v2.y = 15
v3 = v1 + v2

( v3.x now = 25, v3.y now = 35 )

I realize neither of these concepts are in the spirit of QB64, but just imagine.
There are two ways to write error-free programs; only the third one works.
QB64 Tutorial
Reply


Messages In This Thread
Declaring Functions AS TYPEs - by TerryRitchie - 08-16-2023, 02:26 AM
RE: Declaring Functions AS TYPEs - by dbox - 08-16-2023, 02:56 AM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 03:08 AM
RE: Declaring Functions AS TYPEs - by OldMoses - 08-16-2023, 11:53 AM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 12:33 PM
RE: Declaring Functions AS TYPEs - by a740g - 08-16-2023, 12:38 PM
RE: Declaring Functions AS TYPEs - by bplus - 08-16-2023, 02:38 PM
RE: Declaring Functions AS TYPEs - by Kernelpanic - 08-16-2023, 04:14 PM
RE: Declaring Functions AS TYPEs - by grymmjack - 08-16-2023, 09:50 PM
RE: Declaring Functions AS TYPEs - by mnrvovrfc - 08-16-2023, 11:25 PM
RE: Declaring Functions AS TYPEs - by bplus - 08-17-2023, 12:41 AM



Users browsing this thread: 5 Guest(s)