Hi Martin, You have fixed a bug, but introduced one. :-|
Maybe we should rather discus on the list whether it's a bug or not before commit. But it's on your branch and thus I don't complain. Thanks for spotting the missing "if sz <= X.size then return". But now I demonstrate, why I want m := max(sz, 2*X.size); X.cache := resize!(X.cache, X.size, m); X.size := m; and not just X.cache := resize!(X.cache, X.size, 2*X.size); X.size := 2*X.size; . Suppose a new stream s is created. Then someone says a := s.0; b := s.100; After the first command the internal cache array has size for exactly 1 element. The second call calls resize!(s, 100) and after executing your code has room for exactly 2 elements. If you look into the "apply" function then you see that after the resize! call the generator is called to fill the array. No other resize happens. So your code will segfault. :-( So the resize function should read... local resize!(x: %, sz: I): () == { assert(sz > 0); empty? X.cache => { X.cache := new sz; X.size := sz; } Xsize := X.size; if sz <= Xsize then return; -- there is enough room m := max(sz, 2*Xsize); X.cache := resize!(X.cache, Xsize, m); X.size := m; } And please do not leave "import from String" inside that function. It's completely unnecessary. Ralf ------------------------------------------------------------------------- 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 _______________________________________________ Aldor-combinat-devel mailing list Aldor-combinat-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/aldor-combinat-devel