Hi Erik, Can you explain a little better by showing a code example?
Thanks. On Nov 16, 2007 5:44 PM, Erik Arvidsson <[EMAIL PROTECTED]> wrote: > One benefit of StopIteration is that code inside map/some/every etc > can just throw a StopIteration to stop the iteration. The same thing > is harder to keep clean with a hasNext/next pattern. > > > On Nov 16, 2007 5:30 PM, Garrett Smith <[EMAIL PROTECTED]> wrote: > > Which is better? > > > > var nodes : int; > > var widgetMap = Widget.instances; // a map. > > var it:Iterator<string> = widgetMap.getKeys(); > > > > -- this: -- > > > > try { > > widgetMap.get(it.next()).hide(); > > } > > catch(Exception e) { > > if(e instanceof StopIteration) { > > > > } > > } > > > > > > -- or this: -- > > > > while(it.hasNext()) { > > widgetMap.get(it.next()).hide();; > > } > > > > It might be the case that there might be some error > > I want to catch other than StopIteration. In that case, to be > > backwards-compatible and work across implementations, the developer > > must use conditional > > checks inside 1 catch block. > > > > A hasNext() would not prevent the developer from writing such code. > > Omitting hasNext() forces developers to use exception handling for > > non-exceptional condition. > > > > How does using try/catch for normal termination of the loop look? > > > > It looks like all exceptions are unchecked in ES4. correct? (I cannot > > verify this to be true because > > I am unable to access the spec namespace on ecmascript.org.) > > _______________________________________________ > > Es4-discuss mailing list > > Es4-discuss@mozilla.org > > https://mail.mozilla.org/listinfo/es4-discuss > > > > > > -- > erik > -- Programming is a collaborative art. -- Programming is a collaborative art. _______________________________________________ Es4-discuss mailing list Es4-discuss@mozilla.org https://mail.mozilla.org/listinfo/es4-discuss