Skip to content

would be nice to improve the arrays in MINT #51

@SteveJustin1963

Description

@SteveJustin1963

would be nice to improve the arrays in MINT

✅ Comparison of Array Handling: 4tH 3.64 vs SJ Manual MINT v2


1. Declaration and Memory Management

Feature 4tH 3.64 MINT v2
Syntax 16 array arrname [1 2 3] a!
Mutability Fully mutable arrays Immutable once defined (heap-allocated)
Memory Control Explicit cell allocation Auto-allocated on heap; manual deallocation not needed
Stack Involvement Address must be manipulated for access (th, etc.) Address saved in a variable directly, used with ?/?!
Dynamic Sizing Size fixed at declaration Same—fixed size, but easily create new arrays dynamically

2. Access & Mutation

Feature 4tH 3.64 MINT v2
Read arr 0 th @ a 0?
Write 5 arr 0 th ! -222 a0?!
Nested Access Manual offset calc required Native nested arrays with recursive ? access
Byte Arrays Possible with special handling Native with \[ mode and \?, \?!

3. Array Operations

Feature 4tH 3.64 MINT v2
Copy Array smove Manual via loops with /i, ?, ?!
Array Size Manual tracking or dynamic /S operator
Array Depth Not native; emulate with offsets Buggy in MINT v2 (/D documented but broken)
Array of Constants create sizes 18 , 21 , 24 , [a b c] with variables embedded

4. Advanced Features

Feature 4tH 3.64 MINT v2
Associative Arrays Yes via hashtable No native support
Bit Arrays Yes via bit-array, bit-on, etc. No native bit-array support
Function Arrays / FP Support Closures via does> (manual) Anonymous functions inside arrays (partially buggy)
Memory Allocation create, allot, etc. /A for uninitialized memory blocks

🔧 Recommended Upgrades to MINT v2 for Array Support

To make MINT v2 competitive or more usable for real-world array tasks, consider implementing the following:


1. Add Mutable Array Resizing or Cloning

  • Why: MINT arrays are fixed-size and immutable post-declaration.
  • Fix: Add /R (resize) or /C (clone) operator to duplicate arrays to a new location with extended slots.

2. Fix /D (Depth) for Arrays

  • Why: Currently broken, but essential for safe iteration.
  • Fix: Implement working /D to return depth of nested arrays (and differentiate from /S).

3. Add Native smove Equivalent

  • Why: Copying arrays manually with /i and loops is verbose.
  • Fix: Introduce /M or /COPY to clone array contents from one pointer to another.

4. Implement Bit Array Operations

  • Why: Useful for flags, memory-efficient booleans.
  • Fix: Add syntax like bON, bOFF, bTOGGLE, b? mapped to heap offsets.

5. Improve Anonymous Function Array Execution

  • Why: Presently broken/hangs (:/G fails inconsistently).
  • Fix: Resolve bugs in :@ creation and /G execution, especially within nested structures.

6. Add Associative Arrays (Hash Tables)

  • Why: Keyed storage is essential for real applications (like config, cache, maps).
  • Fix: Add native or library-based support for [key val key val] structures with PUT/GET.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions