Ok, so arbitrary rank indexing now works:

////////////
var a2 : int ^ 12 = (1,2,3,4,5,6,7,8,9,10,11,12);

var pa2 = &a2;
var pb2 = C_hack::cast[&(int ^ (3 * 2 * 2))] pa2;
var b2 = *pb2;

for var i  in 0 upto 2 do
  var ii = i :>> 3;
  for var j in 0 upto 1 do
    var jj = j :>> 2;
    for var k in 0 upto 1 do
      var kk = k :>> 2;
      println$ b2 . (ii,jj,kk);
    done
  done
done
////////////////
1
2
3
4
5
6
7
8
9
10
11
12
/////////////////

Note that in the loop we MUST coerce the integer indices
to the correct index types. Support for iterating through
finite sum types will be discussed shortly.

Note also the array starts off in one shape and we use a 
reinterpret cast via a C_hack cast on a pointer to reshape
the array. This is unsafe and we'll have safe ways to do this,
again to be discussed. The CORE operation is simply
the isomorphism which translates between "array of array"
and "array" eg from an array length N of arrays length M
to an array length N * M.

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to