Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arrays inside Types?
#44
I think I’ve finally lost my mind, but I’m planning to attempt to add support for dynamic nested arrays to QB64PE. I’ve recently managed to get support for static nested arrays working, which has encouraged me to take the next step into the dynamic territory.

If we are to implement dynamic nested arrays - a task I am just beginning (first, I need to clarify the intended behavior) - the syntax for ReDim should look like this:

Imagine a type named "test" containing an integer X, a long array A, and a string array B. If we ReDim an array C(100) of this type, we should then be able to reach further in and call something like: Redim C(0).B(20, 50) as String.

In this case, we would be resizing the nested array B via ReDim. Does this approach seem correct to you? The same logic would apply to _Preserve. For example, Redim _Preserve C(0).B(1, 0) as String would increase the first dimension of the nested array B by one element.

Regarding Erase, I propose extending its functionality so we can clear a specific nested array, such as Erase C(0).B. To keep the implementation consistent with C++ logic (where a nested dynamic array acts similarly to a pointer or a vector member within a struct), I suggest the following:

First, the current implementation of Erase must remain fully functional and work on top-level arrays exactly as it does now. Second, Erase must become context-aware. If I call Erase C (the parent array), the parser must ensure a recursive cleanup of all nested dynamic arrays within every element of C to prevent memory leaks. Third, inside the Type definition, the nested array should be represented by a descriptor. This allows us to use ReDim and _Preserve on a per-element basis, mirroring how one would resize a member vector in C++.

Furthermore, I assume we should also support defining bounds within the Type itself, for example:

Type Test
A(1 to 30) as Long, B(minValue to maxValue) as Long
End Type

I guess so, anyway!

I would like to hear your suggestions and opinions before I start digging deep into the Qb64Pe.bas parser and beyond. As for GET and PUT with these variable nested arrays, direct support might be "impossible" - much like how _Mem "doesn't work" with variable - length strings...  So, support is technically possible, just not directly. But that is a task for the very end.

These suggestions seem reasonable to me, but I want to hear your thoughts first.


Reply


Messages In This Thread
Arrays inside Types? - by Ikerkaz - 03-04-2026, 09:44 PM
RE: Arrays inside Types? - by justsomeguy - 03-04-2026, 09:57 PM
RE: Arrays inside Types? - by Jack - 03-04-2026, 10:39 PM
RE: Arrays inside Types? - by bplus - 03-04-2026, 11:45 PM
RE: Arrays inside Types? - by hsiangch_ong - 03-05-2026, 01:32 AM
RE: Arrays inside Types? - by ahenry3068 - 03-05-2026, 04:21 PM
RE: Arrays inside Types? - by Jack - 03-05-2026, 02:14 PM
RE: Arrays inside Types? - by Kernelpanic - 03-05-2026, 03:27 PM
RE: Arrays inside Types? - by Kernelpanic - 03-06-2026, 02:48 PM
RE: Arrays inside Types? - by hsiangch_ong - 03-06-2026, 05:43 PM
RE: Arrays inside Types? - by CookieOscar - 03-06-2026, 06:23 PM
RE: Arrays inside Types? - by bplus - 03-07-2026, 08:29 AM
RE: Arrays inside Types? - by Kernelpanic - 03-06-2026, 09:54 PM
RE: Arrays inside Types? - by Unseen Machine - 03-07-2026, 11:04 AM
RE: Arrays inside Types? - by Jack - 03-07-2026, 12:33 PM
RE: Arrays inside Types? - by bplus - 03-07-2026, 12:42 PM
RE: Arrays inside Types? - by bplus - 03-07-2026, 12:55 PM
RE: Arrays inside Types? - by Jack - 03-07-2026, 03:24 PM
RE: Arrays inside Types? - by SMcNeill - 03-07-2026, 03:46 PM
RE: Arrays inside Types? - by Jack - 03-07-2026, 03:59 PM
RE: Arrays inside Types? - by Jack - 03-07-2026, 04:23 PM
RE: Arrays inside Types? - by bplus - 03-08-2026, 07:20 PM
RE: Arrays inside Types? - by Kernelpanic - 03-09-2026, 06:01 PM
RE: Arrays inside Types? - by Petr - 03-09-2026, 08:02 PM
RE: Arrays inside Types? - by Jack - 03-09-2026, 08:14 PM
RE: Arrays inside Types? - by Petr - 03-09-2026, 08:19 PM
RE: Arrays inside Types? - by Jack - 03-09-2026, 08:23 PM
RE: Arrays inside Types? - by Jack - 03-09-2026, 08:45 PM
RE: Arrays inside Types? - by bplus - 03-10-2026, 12:51 AM
RE: Arrays inside Types? - by Petr - 03-09-2026, 08:52 PM
RE: Arrays inside Types? - by justsomeguy - 03-09-2026, 11:23 PM
RE: Arrays inside Types? - by Jack - 03-10-2026, 12:31 AM
RE: Arrays inside Types? - by Jack - 03-10-2026, 03:54 AM
RE: Arrays inside Types? - by bplus - 03-10-2026, 10:39 AM
RE: Arrays inside Types? - by Petr - 03-10-2026, 05:32 PM
RE: Arrays inside Types? - by SpriggsySpriggs - 03-10-2026, 06:03 PM
RE: Arrays inside Types? - by Jack - 03-10-2026, 06:18 PM
RE: Arrays inside Types? - by Jack - 03-10-2026, 06:30 PM
RE: Arrays inside Types? - by Petr - 03-10-2026, 07:16 PM
RE: Arrays inside Types? - by Ikerkaz - 03-11-2026, 03:11 PM
RE: Arrays inside Types? - by SMcNeill - 03-11-2026, 03:48 PM
RE: Arrays inside Types? - by Petr - 03-11-2026, 08:44 PM
RE: Arrays inside Types? - by Jack - 03-11-2026, 09:01 PM
RE: Arrays inside Types? - by Petr - 10 hours ago

Possibly Related Threads…
Thread Author Replies Views Last Post
  Arrays as UDTs Pete 26 1,271 02-06-2026, 04:31 AM
Last Post: bplus
  Preserving multi-dim arrays Pete 5 444 12-19-2025, 03:17 PM
Last Post: Dimster
  Array out of passing arrays... Pete 2 420 09-22-2025, 08:53 PM
Last Post: ahenry3068
  Methods in types bobalooie 7 1,600 01-30-2025, 08:00 PM
Last Post: Pete
  C++ types > QB64 types: do we have an equivalent QB64PE page? madscijr 5 1,168 06-01-2024, 03:44 AM
Last Post: grymmjack

Forum Jump:


Users browsing this thread: 1 Guest(s)