This is a multi-part message in MIME format.

------extPart_000_0057_01C129DE.F084AD30
Content-Type: text/plain;
	charsetso-8859-1"
Content-Transfer-Encoding: quoted-printable

"Joshua Drake" <jd.nospam / commandprompt.com> wrote in message news:to335diag2p2ff / corp.supernews.com...
> Hello,
> 
> I am the author of the Programming in ruby on IBM Developworks.
...
> I am getting ready to release the second article, but I want to get
> some feedback from the ruby community first. I would like the second
> article to be more ruby centric and will need some help.
...
>  while 1
...
>  end


Although this loops forever, as you intend, I would guess that it doesn't do so for the reason you think.  Also it is very misleading code because people who are used to C would expect that 'while 0 ... end' would not loop at all, but in Ruby it is also an infinite loop.  Ruby treats all values except false and nil as meaning 'true'.

Secondly, Ruby provides an infinite loop method: 'loop {block}'.  I would use this in preference to 'while true ... end'.

Finally, please refactor your program before publishing the article.  The code, as it is, is poorly structured and therefore not a good example of Ruby -- the script uses global variables for no reason, the methods are far too long, code structures are repeated instead of being abstracted as methods, and so on.  Also, the program doesn't use any of Ruby's interesting features, such as creating domain specific iteration statements.  I would suggest rewriting the example using these kind of idioms, otherwise all you are demonstrating is that Ruby has a different syntax to Perl.  You could also demonstrate Ruby's open classes by defining your iterators as methods of the built-in File class, and demonstrate Ruby's singleton methods by adding methods to the STDIN object.

E.g. the main loop should look something like this:

File.open( address_file ) do |file|
    STDIN.each_address_input do |addr|
        file.write_address( addr )
    end
end

The each_address_input method is a singleton method that reads addresses from the input stream until the user inputs END. 

The write_address method would write an address into the file in the standard format.


------extPart_000_0057_01C129DE.F084AD30
Content-Type: text/html;
	charsetso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV>"Joshua Drake" &lt;<A 
href="mailto:jd.nospam / commandprompt.com">jd.nospam / commandprompt.com</A>&gt; 
wrote in message <A 
href="news:to335diag2p2ff / corp.supernews.com">news:to335diag2p2ff / corp.supernews.com</A>...</DIV>
<DIV>&gt; Hello,<BR>&gt; <BR>&gt; I am the author of the Programming in ruby on 
IBM Developworks.<BR>...<BR>&gt; I am getting ready to release the second 
article, but I want to get<BR>&gt; some feedback from the ruby community first. 
I would like the second<BR>&gt; article to be more ruby centric and will need 
some help.<BR>...</DIV>
<DIV>&gt; &nbsp;while 1</DIV>
<DIV>...<BR>&gt; &nbsp;end</DIV>
<DIV><BR>&nbsp;</DIV>
<DIV>Although this loops forever, as you intend, I would guess that it doesn't 
do so for the reason you think.&nbsp; Also it is very misleading code because 
people who are used to C would expect that 'while 0 ... end' would not loop at 
all, but in Ruby it is also an infinite loop.&nbsp; Ruby treats all values 
except false and nil as meaning 'true'.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Secondly, Ruby provides an infinite loop method: 'loop {block}'.&nbsp; I 
would use this in preference to 'while true ... end'.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Finally, please refactor your program before&nbsp;publishing the 
article.&nbsp; The code, as it is, is poorly structured and therefore not a good 
example of Ruby -- the script uses global variables for no reason, the methods 
are far too long, code structures are repeated instead of being abstracted as 
methods, and so on.&nbsp; Also, the&nbsp;program doesn't use any of Ruby's 
interesting features, such as creating domain specific iteration 
statements.&nbsp; I would suggest rewriting the example using these kind of 
idioms, otherwise all you are demonstrating is that Ruby has a different syntax 
to Perl.&nbsp; You could also demonstrate Ruby's open classes by defining your 
iterators as methods of the&nbsp;built-in File class, and demonstrate Ruby's 
singleton methods&nbsp;by adding methods to the&nbsp;STDIN object.</DIV>
<DIV>&nbsp;</DIV>
<DIV>E.g. the main loop should look something like this:</DIV>
<DIV>&nbsp;</DIV>
<DIV>File.open( address_file ) do |file|</DIV>
<DIV>&nbsp;&nbsp;&nbsp; STDIN.each_address_input do |addr|</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file.write_address( addr )</DIV>
<DIV>&nbsp;&nbsp;&nbsp; end</DIV>
<DIV>end</DIV>
<DIV>&nbsp;</DIV>
<DIV>The each_address_input method is a singleton method that reads addresses 
from the input stream until the user inputs END.&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>The write_address method would write an address into the file in the 
standard format.</DIV>
<DIV>&nbsp;</DIV></FONT></DIV></BODY></HTML>

------extPart_000_0057_01C129DE.F084AD30--