Re: else on for

new topic     » goto parent     » topic index » view thread      » older message » newer message

--Alt-Boundary-24703.13536828
Content-description: Mail message body

On 7 Aug 2003 at 7:00, David Cuny wrote:

> 
> 
> Karl Bochert wrote:
> 
> > I very much like [else],  but shouldn't the sense be reversed?
> >
> >     for i = 1 to length( s )
> >        if s[i] = 999 then
> >           break
> >        end if
> >     else
> >        printf( "999 WAS found!!" )
> >     end for
> 
> I see what you mean, but no. At least, not the way Python implements it, which
>
> is where I stole it from. Think of it this way: knowing the value was found 
> it the easy part. That it wasn't found is more problematic.
> 
Interesting. It took a while, but I understand (and agree!).
It is distressing that it could so thoroughly mislead me at first glance.
It does seem that 'else' here has a very different behavior than the else
in if-else.

Maybe:

     for i = 1 to length( s )
        if s[i] = 999 then
           break
        end if
     then
        printf ("999 NOT found")
     end for

would be more consistant with the other uses of else & then.
The not found clause is 'after' rather than 'otherwise'.

Karl Bochert



--Alt-Boundary-24703.13536828
Content-type: text/html; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

<?xml  version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial"><span style="font-size:10pt">On 7 Aug 2003
at 7:00, David Cuny wrote:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; ============ The Euphoria Mailing List ============
</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; Karl Bochert wrote:</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt; I very much like [else],  but shouldn't the
sense be reversed?</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt;</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt;     for i = 1 to length( s
)</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt;        if
s[i] = 999 then</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt;
&gt;          
break</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt;        end
if</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt;     else</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt;       
printf( &quot;999 WAS found!!&quot; )</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; &gt;     end
for</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; I see what you mean, but no. At least, not the way
Python implements it, which </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; is where I stole it from. Think of it this way:
knowing the value was found </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; it the easy part. That it wasn't found is more
problematic.</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span
style="font-size:10pt">&gt; </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Interesting.
It took a while, but I understand (and agree!).</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">It is
distressing that it could so thoroughly mislead me at first
glance.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">It does seem
that 'else' here has a very different behavior than the else</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">in
if-else.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">Maybe:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">     for i = 1 to length( s
)</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">        if s[i] = 999
then</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">          
break</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">        end
if</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">     then</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">        printf
(&quot;999 NOT found&quot;)</span></font></div>
<div align="left"><font face="Arial"><span
style="font-size:10pt">     end for</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">would be more
consistant with the other uses of else &amp; then.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">The not found
clause is 'after' rather than 'otherwise'.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Karl
Bochert</span></font></div>
<div align="left"><br/>
</div>
<div align="left"></div>

--Alt-Boundary-24703.13536828--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu