Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Declaring Functions AS TYPEs
#14
This UDT as function thing is kewl, but there is a simple reason why "internally" they are being passed around as pointers.

If one such variable of type UDT has to be passed by value, or become the return value of a function, it will have to be copied. But QB64 might already do this with strings because QuickBASIC did it. This could cause performance issues.

Purebasic doesn't allow UDT's passed by value. The parameter to subprograms for an UDT must be a pointer. It's because the compiler cannot asume what is the size of one type which is not a simple one like 64-bit integer. Otherwise it has to decide what will be a character, if it's Unicode or not.

The thing with _MEM works with any UDT. What sucks is that one has to use "m.OFFSET + x" notation to get to the fields and figure out the precise order of the types of the members, as listed in the source code. If all members are integer or floating point then it's easier, but real life in programming is never that easy. Another thing that sucks is that the UDT could never be the direct return value of a FUNCTION. It could only depend on the SUB side-effect to change it because "internally" only a pointer is being involved.
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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Arrays inside Types? Ikerkaz 20 511 Yesterday, 04:23 PM
Last Post: Jack
  Methods in types bobalooie 7 1,581 01-30-2025, 08:00 PM
Last Post: Pete
  C++ types > QB64 types: do we have an equivalent QB64PE page? madscijr 5 1,137 06-01-2024, 03:44 AM
Last Post: grymmjack
  Date functions dritter 31 5,029 05-20-2024, 04:22 PM
Last Post: dano
  need help converting old style def fn functions madscijr 11 2,904 07-27-2022, 02:07 AM
Last Post: madscijr

Forum Jump:


Users browsing this thread: