Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Icon > Re: Generator "...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 6 Topic 132 of 188
Post > Topic >>

Re: Generator "Cleanup" Question

by espie@[EMAIL PROTECTED] (Marc Espie) Nov 27, 2006 at 08:45 PM

In article <ekfev7$1d8l$1@[EMAIL PROTECTED]
>,
Gregg Townsend <gmt@[EMAIL PROTECTED]
> wrote:
>When a generator suspends, it can't assume it will ever be resumed.
>For the example you gave, I'd probably read fetch all the results
>into an array, close the database connection, and then generate the
>array contents.  Of course, that assumes that the results can fit
>in memory reasonably.

I don't know if you recall, but I ran into a similar issue a few
years ago. I wanted to re-implement find using KMP, and I couldn't
find a place to free the extra data structure. This is about the
same problem here...

I don't know if unicon has any solution for that, but Icon definitely
lacks some `finally' mechanism, for lack of a better word. There are
ways to know a generator goes out of scope (without co-processes, one
just has to look at the enclosing expressions), and there are compelling
reasons to allow a generator to release stuff properly at some point.

As another example, assume I have a generator that yields lines of a file,
and that I want to lock the file for concurrent accesses. With the
current generator model, I simply can't, because there is no safe way
to ensure the file will be unlocked when the generator ends.
 




 6 Posts in Topic:
Generator "Cleanup" Question
Cp200205@[EMAIL PROTECTED  2006-11-26 08:22:20 
Re: Generator "Cleanup" Question
gmt@[EMAIL PROTECTED] (G  2006-11-27 19:40:23 
Re: Generator "Cleanup" Question
espie@[EMAIL PROTECTED]   2006-11-27 20:45:30 
Re: Generator "Cleanup" Question
Steve Wampler <swample  2006-11-27 14:12:14 
Re: Generator "Cleanup" Question
Cp200205@[EMAIL PROTECTED  2006-11-27 14:15:29 
Re: Generator "Cleanup" Question
Steve Wampler <swample  2006-11-27 16:22:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 6:10:55 CDT 2008.