News:

  • August 14, 2026, 09:09:22 PM

Login with username, password and session length

Author Topic: Creation of Data Block as 2D Array  (Read 10534 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Creation of Data Block as 2D Array
« on: March 27, 2023, 03:18:12 PM »
I want to create a 2D data block, and the only way I can think to do it is to create a UDT for the second dimension with enough elements for the second dimension, then create an array of that.   So then the elements of the UDT have to have names, which means the final syntax is like MyBlock[1].Fld2, as opposed to MyBlock[1][2] or something like that.   Is there a way to get a generic unnamed second dimension?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Creation of Data Block as 2D Array
« Reply #1 on: March 27, 2023, 04:03:29 PM »

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Creation of Data Block as 2D Array
« Reply #2 on: March 27, 2023, 04:47:03 PM »
Yeah, I remember that way, but since then there was some official support for multi-dim arrays and I couldn't remember if it was arrays of UDTs that were themselves in effect arrays or if there was something more direct.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Creation of Data Block as 2D Array
« Reply #3 on: March 27, 2023, 04:49:17 PM »
Yeah, I remember that way, but since then there was some official support for multi-dim arrays and I couldn't remember if it was arrays of UDTs that were themselves in effect arrays or if there was something more direct.

Direct support of multidimensional arrays (2-D at least) needs to happen.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Creation of Data Block as 2D Array
« Reply #4 on: March 27, 2023, 06:59:00 PM »
N-dimensional arrays can easily be done via a single dimension array.  Oh, and it works with a block of UDTs (not just built-in types).

The C programming language has been doing this since the 70's.  Just write a subroutine or a MATH box to do the calculation.

Believe it or not, the MATH box will be MUCH faster than anything we have to do "natively" since the "native" must be implemented generically.  So if you don't mind slow array lookups on a 5 dimensional array, we'll implement it "natively" also.  ;D

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Creation of Data Block as 2D Array
« Reply #5 on: March 28, 2023, 12:19:01 PM »
Believe it or not, the MATH box will be MUCH faster than anything we have to do "natively" since the "native" must be implemented generically.  So if you don't mind slow array lookups on a 5 dimensional array, we'll implement it "natively" also.  ;D

OK, let's do that! :D Actually, just trying to abstract it one more level for mental-model's sake, and not worrying too much about speed.  Having it as an option would be ideal because you can choose between syntax and speed.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

rlp122

  • Sr. Member
  • ****
  • Posts: 92
Re: Creation of Data Block as 2D Array
« Reply #6 on: March 28, 2023, 10:47:23 PM »
So if you don't mind slow array lookups on a 5 dimensional array, we'll implement it "natively" also.  ;D

Personally I don't mid it being a bit "slow".  I write programs to be readable by a third grader if possible.  I'd rather give up a bit of speed and avoid phone calls than have someone calling every ten minutes going; "What's this do???"

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6170
  • Yes Pinky, Do-more will control the world!
Re: Creation of Data Block as 2D Array
« Reply #7 on: March 30, 2023, 03:00:19 PM »
There are real and varied structural limits in how we reference image register. Changing that would be hard.

If we eliminated the requirement that the data be stored in image register, or more specifically, that it be referenceable as image register, we have a great deal of flexibility. The answer to that is tables, which we've mentioned before. I think we are going to do that.

Some thoughts on tables...
1. A table is a 1 to n dimension collection of simple or complex data elements.
2. There may be the ability to have small tables in retentive memory, but generally they will live in non-retentive bulk ram.
3. There will be a normal heap item associated with each table. It will contain stats on the table, and likely some private data with implementation details.
4. I'd expect multiple forms of table: FIFO, LIFO, sorted, multi-dimension array, etc. TBD.
5. There will be multi-scan instructions for adding, inserting, removing, etc records from tables.
6. There will be standalone instructions for reading and writing records, as well as MATH box functions for the same. In general, record read/write access is single scan blocking, while the instructions from #5 are generally multi-scan non-blocking. Unsorted append might be an exception.
7. We are thinking the MATH box grammar might be something like MyTable{dim1exp, dim2exp, ..., dimnexp} and would have both l-value and r-value variants. Using the curly brace would help in the parsing, and make it easy to discern table access from function calls.
8. Because table entries aren't normal image register, comm/status would be provided through a difference mechanism, but we should be able to provide reasonable access.
9. TBD...

"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO