From: "Ara.T.Howard" Date: 2005-06-18T00:03:24+09:00 Subject: Re: Super-scalar Optimizations On Fri, 17 Jun 2005, Gavin Kistner wrote: > On Jun 17, 2005, at 6:40 AM, Robert Klemme wrote: >> Even more so: what's the point of a loop that is alway run only once? > > Er, the loop doesn't run once, only the initialization code. The loop runs > forever. > > > On Jun 17, 2005, at 6:11 AM, Devin Mullins wrote: >> And wouldn't it be faster still just to pull foo = bar out of the while >> loop? :) > > I actually flubbed the example slightly. It should have been: > > already_run = false > while true > do_something( ) > foo = bar if !already_run > already_run = true > end > > Where "do_something()" was actually about 15 lines of code. The alternative > would have been: > > do_something( ) > foo = bar > while true > do_something( ) > end > > which is not very DRY when do_something( ) is a large block of code. sure it is - block being the key word here: do_something = lambda {|arg| ... 15 lines of code true } do_something[arg] and (foo = bar) and loop{ do_something[arg] } pulling out little blocks of code that are re-used by can't be methods due to context senstive behaviour or because they are just too small is what lambda abstraction is for ;-) cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================