From: Nathan Baker on 10 May 2010 00:13 "Dave Harris" <brangdon(a)cix.co.uk> wrote in message news:memo.20100509163449.5892C(a)brangdon.cix.compulink.co.uk... > > Yes. It led to simple code, but that was partly because all the > complexity was hidden behind an iterator. Nathan Baker's version exposes > some of that complexity, and I think illustrates how hard it is to get it > right. > Perhaps the words "simple" and "complexity" have different meanings to different people because of their different training and the goals they've been conditioned to target?? Juha's code uses 3 loop constructs, 4 conditionals, and 2 exit points. Mine uses 1 loop construct, 2 conditionals, and 1 exit point. Nathan.
From: Seebs on 10 May 2010 00:29 On 2010-05-10, Nathan Baker <nathancbaker(a)gmail.com> wrote: > Perhaps the words "simple" and "complexity" have different meanings to > different people because of their different training and the goals they've > been conditioned to target?? Quite possible. Idioms are much simpler than any analysis of their components would suggest. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Nathan Baker on 10 May 2010 00:29 "Daniel T." <daniel_t(a)earthlink.net> wrote in message news:daniel_t-5C8D00.12442509052010(a)70-3-168-216.pools.spcsdns.net... > > But in any case, no more can be said unless a real use-case is > presented. All I'm saying is that the assumption that three loops are > necessary to express an O(n) algorithm is inappropriate. Perhaps the two nested 'for' loops could be justified if their indexes (yInd and zInd) were to actually "come in to play" within the algo? Otherwise, they represent wasted (not used for any task that can't be accomplished via other means) resource allocation. Maybe if we are doing some sort of gradient-fill where we incredmentally increase the RGB values of pixels? xInd, yInd, zInd represent the R, G, B values that we set for each pass of the loop? We stop when we get to a certain color already present on the screen? Nathan.
From: Richard Heathfield on 10 May 2010 01:46 Seebs wrote: > On 2010-05-10, Nathan Baker <nathancbaker(a)gmail.com> wrote: >> Perhaps the words "simple" and "complexity" have different meanings to >> different people because of their different training and the goals they've >> been conditioned to target?? > > Quite possible. Idioms are much simpler than any analysis of their > components would suggest. Yes. But, for me, SESE is idiomatic. Not too many years ago, I posted a mild parody of SEME code of the sort that I used to have to maintain, which made the case for SESE much more effectively than a tiny loop does for SEME. I'd dig it out if I weren't so lazy. Basically, it was lots of code with many loops, not all of them nested by any means, each apparently unrelated to others, with seemingly random control flow changes coupling everything together into a tight, unmanageable mess. No, on reflection it wasn't a parody at all. It was a pretty fair description of some of the code I've had to maintain. It is probably fair to say that my advocacy of SESE is a mild (and relatively harmless) over-reaction to those torrid times. -- Richard Heathfield <http://www.cpax.org.uk> Email: -http://www. +rjh@ "Usenet is a strange place" - dmr 29 July 1999 Sig line vacant - apply within
From: Seebs on 10 May 2010 03:12
On 2010-05-10, Richard Heathfield <rjh(a)see.sig.invalid> wrote: > Yes. But, for me, SESE is idiomatic. That's not an idiom, that's a policy. An idiom is a very specific way of writing a loop, not a general rule as to how loops should be written. for (i = 0; i < N; ++i) is an idiom. SESE is a policy about how code should be written; it's not an idiom, because you have to look at the details of the logic for every separate loop to figure out how you might do it, and there's multiple choices. > It is probably fair to say that my advocacy of SESE is a mild (and > relatively harmless) over-reaction to those torrid times. Yes. But again, I point out that we had someone do a SESE rewrite of something, and several people misunderstood the rewrite, while no one seems to have had any trouble at all understanding the SEME version. Simple rules with exceptions are easier for humans to process than complicated rules. As long as the people maintaining the code are human, there will be a large set of SEME loops which are clearer to readers in general than any possible SESE equivalent. ("in general" meaning that, if you take an arbitrary random sample of developers, you will find that fewer of them misunderstand the SEME loops than the SESE ones.) There are, of course, a large set of loops where it goes the other way. My response to this is to say that I'll use whichever seems to be most expressive and clear. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! |