salmanahmad / silo

The Silo Programming Language
0 stars 0 forks source link

Fix Muli dimensional arrays #108

Open salmanahmad opened 10 years ago

salmanahmad commented 10 years ago

This create a compilation error:

ticTacToe : array(array(String)) = arraynew(String, 3, 3)
salmanahmad commented 10 years ago

Also add test cases...

salmanahmad commented 10 years ago

Some syntaxes that could be useful?


pass array as an argument... varargs....

list | get(3) | get(4)

list | get(3, 4, 5)

get(list, 3, 4, 5)

list : array(int, 4) = array(int, 2)(1, 2, 3, 4, 5, 6, 7)

array(int)
Array.of(int)
Matrix.new(int, 4, 3, 4)

array()
array[int, 5]()

Matrix? Multi-dimensional array?

object[5]
object[][][][][]
object[1][2][3]

object[0] {2 3 4}

Array.multidimensional
array(int)

array(int, 5)

array(java.lang.Object, 4)

list : array(int) = arrayinit(int, 1 2 3 4 5 6 7 78)
list : array(int 2) = arrayinit(array(int), arrayinit(int 2 3 4 5 6 7), arrayinit(int 2 3 4 5 6 7))

list : Array.new(int
    (1 2)
    (3 4)
)

list : array(int (((1))))

list : array(array(array(int))) = 

??? Have I been going about this wrong all along? Should I have just created specialforms for all JVM instructions and then implement all the higher stuff as macros? I already have invokevirtual and newarray... Also, Why is access / assign / invoke so complicated. Can I simplify those if I went through macros?

A type reference that I could use...
    array(int, 2)

    klass : Class = array(int, 4) - It cannot be the same as the init / capacity forms
    a : array(int, 2) = ...

Macros / specialform to initialize with data
    a : array(int) = Array.init(int, 1 2 3 4 5 6 7 8)

    array(int, 2)(1 2 3 4 45 4 2 3 4) --- this has to be a specialform...not a macro

    initarray(int, 1, 2, 3, 4, 5, 6)
    array(int)(1 2 3 4 5 6 7 8 9)
    Array.new(array(int, 2), ((1 2 3)))
    arrayinit(array(int, 2), (((1, 2))))
    arrayinit(int, 1, 2, 3, 4, 5, 6, 7, 8) --- only single dimensions

Create an array with capacity
    arraynew(int, 2, 3, 4, 5, 6)

Operations to set and get the array
    Should I add special forms for Array.set() Array.get()
    Should I augment access / assign / invoke?

array(Var)(1, 2, 3, 4, 5)

Type signature of array
    array(array(array(array(int))))
    array(int, 4)

Create an array with initial data
    $type$(1, 2, 3, 4, 5, 6)
    $type$((1 2) (3 4))

Create an empty array with capacity
    Array.alloc(int, 1, 3, 4, 5, 6, 7)