This now works (I think .. ):

////////////////////////////
#import <flx.flxh>

var a = mkuiv[int](size 10);
a+=1;
a+=2;
print "len a = "; print$ len a; endl;
print "maxlen a = "; print$ maxlen a; endl;
print$ a.[0]; print ","; print a.[1]; endl;
////////////////////////////


The generators mkiv and mkuiv create varrays of maximum length n,
set to length n and 0 respectively.

You can get the current length with len, and maximum length with maxlen.

A new element can be appended at the end using operator +=.

varrays are heap pointers, so passing a varray UNLIKE an array,
is pass by reference.

Subscript access is currently not bounds checked:
appending is.

This is a minimal interface .. more to be done.
Note that the maxlen argument must be type size,
however any integer can be used for subscripting.

The gc has been modified to support varrays.
In the process I changed the way finalisers work: the RTTI finaliser
is now for a single element (including for array as well as varrays,
if they're heap allocated).

Note that because malloc() is used, extension can't fail due
to lack of memory. However for a large array, mmap should be used
anyhow, which means only VM is actually committed, not RAM.

A version that doesn't even commit RAM would be nice.

If we add a clone function, we can make variable length arrays
of *unbounded* length by creating a new (bigger) array and coping
the elements from the old array.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to