<?xml version="1.0" encoding="windows-1252"?>
<node id="253453" title="Re: Re: Prolegemona To A Future Scripting Language: Game Of Life In Perl 6" created="2003-04-27 02:33:23" updated="2005-01-26 09:01:04">
<type id="11">
note</type>
<author id="194378">
jkahn</author>
<data>
<field name="doctext">
Seems like the &lt;code&gt;method display&lt;/code&gt; as written would actually print all the cells in one row -- &lt;code&gt;method iterate&lt;/code&gt; doesn't have an explicit hook for "reached end of line".  That's fine, since we have &lt;code&gt;$.max&lt;/code&gt; available within the object.
&lt;p&gt;I think &lt;code&gt;method display&lt;/code&gt; should actually look like this:
&lt;code&gt;
 method display
  {
    iterate 
    { 
      print $.grid[$^x][$^y] ?? '+' :: '.';
      print "\n" if ($^x == $.max);
         # print each row on own line
    }
    print "\n"; # blank line follows grid
    print "Turn $(++$.count), press enter to continue"
    print " or ctl-c to quit";
    &lt;$*IN&gt;;
    .calculate();
  } # end method display
&lt;/code&gt;
&lt;p&gt;
A separate style comment: wouldn't it be a bit cleaner to remove the &lt;code&gt;.calculate();&lt;/code&gt; line from &lt;code&gt;method display&lt;/code&gt; and change the &lt;code&gt;loop&lt;/code&gt; at the top so that it reads:

&lt;code&gt;
loop { $life.display(); $life.calculate(); }
&lt;/code&gt;

Then there's no nasty surprise when someone does:
&lt;code&gt;
  # somewhere far, far, away
  $life.display;
  `shell-script;clear`; # weird stuff on screen tty
  $life.display; # refresh terminal *only*
&lt;/code&gt;
later. I recognize that's personal preference, but Side Effects Are Scary.
</field>
<field name="root_node">
253366</field>
<field name="parent_node">
253438</field>
</data>
</node>
