On Thu, 2007-03-29 at 22:06 -0700, Erick Tryzelaar wrote:
> I'd like to make a simpler frontend to tre by wrapping the apis to 
> return felix-native data structures, such as varray.

Yup, that's a good idea and one of the main reasons for 
implementing varray.

> Is it possible to 
> pass in a pointer to varray so that it knows that it owns it, and will 
> delete it when it's garbage collected?

I don't think so. varray[t] has n elements of type t, where n
is stored in the dynamic header of the object. That value can
ONLY be set by using a varray at the moment.

Note also the varray[t] has static shape t, so you cannot
cast a tuple to one either, since array[t,3] for example
uses a shape object of type array[t] with the static (in shape)
count set to 3.

However I see no problem: just copy the array. The hard part is
knowing how long to make the C array for tre .. only tre knows
how many groups there are. Note that tre will not exceed the
specified array length .. you just lose the trailing groups.

I think there's a way to find how many groups there are in a
compiled regex, isn't there?

> And speaking of data structures, what should we use as our default 
> return type? varrays or lists?

Probably a varray. The reason is Posix defines subgroups by integers.
It's not very nice, but that's the price for dynamic string regexps.

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

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to