skaller wrote: > > Er no, the problem is you need the nsub value BEFORE you actually > do a regexp, otherwise you can't tell how long the array needs to be > to hold the matches.
I'm confused, I'm basing this off of your tre bindings. :) Here's what you wrote for doing a match: fun tre_regexec (re_in: tre_regex_t) (x:string): int * int * ptr[regmatch_t] = { var re = re_in; val nmatches = nsub$ addr re; var matches = Carray::array_alloc[regmatch_t] nmatches; var res = _tre_regexec(addr re, x, nmatches, matches); return res,nmatches,matches; } Does this not work? > It isn't .. otherwise I would have already done it :) > > Also, varray access should probably be made safe, the way Ocaml > does it: if you use > > s.[i] > > notation it should be bounds checked, if you want fast access then > you have to use functions like 'get_elt s i'. > > The problem is that in > > s.[i]=x; I'll do this. >>>> 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. >>> >> What do you think for in general? > > I don't understand what you mean 'in general' :) What I mean is there are a variety of functions that can return a list of things. Consider a glob-like function, or a database returning a list of rows. What should this data type be? Python obviously prefers their array/list, but we have a couple different structures we could use, including streams and generators. What should most of our functions return? -e ------------------------------------------------------------------------- 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