From: MenTaLguY Date: 2005-12-10T14:01:43+09:00 Subject: Re: next, retry, break? --=-dGviWF61d6iUg6du6Iv8 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Sat, 2005-12-10 at 11:29 +0900, Yukihiro Matsumoto wrote: > If you want "redo" to work, you have to initialize your @current_grob > at the beginning of the iterating method. Since many expect "each" to > enumerate all the values in the collection, initializing at the top is > a good thing in general. Thanks... This is for a stream class, so it would be a "consuming" each like IO#each. In that case not initializing is okay (it should behave just like IO#each does). The problem was that I was not advancing the stream pointer until after the yield -- solved with 'ensure'. Just to be sure I understand correctly now: redo: jumps to the start of the block next: jumps to the end of the block using the given value (or nil) as the block's result retry: unwinds the stack to the call site of the "closest" yielding method, calling it again with the same arguments break: unwinds the stack to the call site of the "closest" yielding method, using the given value (or nil) as the method's result Is that right? If so, what if I want retry or break to unwind further (e.g. because I am implementing one iterator in terms of another)? -mental --=-dGviWF61d6iUg6du6Iv8 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBDmlwNcUNIGiXCc4MRAlpaAJ4iU8eC25mk9sbu8JQEhDoATUb31wCeKYot AQu7Iw7BHZ6o4jYv4YcR19M= =/KIE -----END PGP SIGNATURE----- --=-dGviWF61d6iUg6du6Iv8--