why no "do : until"?
r_m_guy at my-deja.com
r_m_guy at my-deja.com
Fri Jan 5 12:40:03 EST 2001
In article <92o7gh$nd2$1 at nnrp1.deja.com>,
henry_crun3583 at my-deja.com wrote:
> I can't really see a problem with any of the
suggested indents.
>
> > > do:
> > > R=Themistor.ReadResistance()
> > > T=R_to_Temperature(R)
> > > until (T>=25)
>
> Is neater but I don't have any trouble reading
(b)
>
> > > do:
> > > R=Themistor.ReadResistance()
> > > T=R_to_Temperature(R)
> > > until (T>=25)
>
> if thats what the parser likes. But why can't
the parser ingnore extra
> indents, in the same way C,Pascal ignore blocks
added purely for
> clarity? If you want some extra indent, add it.
>
> > > do:
> > > R=Themistor.ReadResistance()
> > > T=R_to_Temperature(R)
> > > until (T>=25)
>
> Tim Peters raises the question of do: while vs
do: until
>
> Personally I think "do: until" more often
reflects the algorithm I am
> representing, however "do: while" leads to a
single consistent test for
> both ("while:" & "do:while") loops, and can
reduce bugs, especially
> when you decide to change a loop from one to
the other and forget to
> fix the terminate condition. (I am a VERY vague
programmer)
>
> Sent via Deja.com
> http://www.deja.com/
>
The whole "while" and "do:while" thing seems
arbitrary to me, I think, that there should
really be one loop construct called "loop:" the
syntax should be
loop:
<statements>
if <test>: continue
<statements>
if <test>: break
This way there is only 1 metaphor for a loop, if
you always want the statements to execute at
least once(like do/while), do this:
loop:
<statements>
if <test>: break
if you want the statements to execute
conditionally do this
loop:
if <test>: break
<statements>
All this approach does is replace the artificial
contruct "while 1" with a single natural "loop"
construct.
Just my 2 cents, but it seems sensible to me.
Richard
Sent via Deja.com
http://www.deja.com/
More information about the Python-list
mailing list