Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Prolegemona To A Future Scripting Language: Game Of Life In Perl 6

by jkahn (Friar)
on Apr 27, 2003 at 06:33 UTC ( #253453=note: print w/replies, xml ) Need Help??


in reply to Re: Prolegemona To A Future Scripting Language: Game Of Life In Perl 6
in thread Prolegemona To A Future Scripting Language: Game Of Life In Perl 6

Seems like the method display as written would actually print all the cells in one row -- method iterate doesn't have an explicit hook for "reached end of line". That's fine, since we have $.max available within the object.

I think method display should actually look like this:

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"; <$*IN>; .calculate(); } # end method display

A separate style comment: wouldn't it be a bit cleaner to remove the .calculate(); line from method display and change the loop at the top so that it reads:

loop { $life.display(); $life.calculate(); }
Then there's no nasty surprise when someone does:
# somewhere far, far, away $life.display; `shell-script;clear`; # weird stuff on screen tty $life.display; # refresh terminal *only*
later. I recognize that's personal preference, but Side Effects Are Scary.

Replies are listed 'Best First'.
Re: Re: Re: Prolegemona To A Future Scripting Language: Game Of Life In Perl 6
by TheDamian (Priest) on Apr 27, 2003 at 21:57 UTC
    As for changing the control flow in .display, yes, I was tempted to do so too.

    But that went beyond "idiomaticization" and became an issue of software engineering. In the end I deliberately didn't hoist the call to .calculate because I felt it was more important to preserve as much comparability with the original as was consistent with an idiomatic Perl 6 implementation.

Re: Re: Re: Prolegemona To A Future Scripting Language: Game Of Life In Perl 6
by TheDamian (Priest) on Apr 27, 2003 at 21:44 UTC
    Quite so. Fixed in the original node. Thanks!

    (Hopefully someone will tie this back to the thread on "Damian Isn't Infallible" :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://253453]
help
Chatterbox?
[Marshall]: stevieb wish you well with water problems, my water was off all day Monday for repairs. Any more progress on .exe info problem?.
[stevieb]: Marshall: no. I commented on the thread yesterday. Visual Studio updates the tags ok, but corrupts the exe
[stevieb]: I advised the OP that a possible workaround would be to add a version function/flag that displays the required copyright/license info instead
[Marshall]: Darn! I'll look at the thread. Must not be updatinga byte count somewhere. The .exe format is a complex critter.
[stevieb]: that way, it's still "hard coded" into the exe at least, despite not being visible via Properties
[Marshall]: I also looked into PerlApp from Active State, but they don't sell their Dev Kit independent of a very expensive ($1,200) per year license anymore.
[Corion]: I would assume that the PE format hasn't changed that much since the days of yore, but it seems that I would be wrong in that assumption
[Marshall]: When I bought my copy 15+ years ago, it was just a couple hundred bucks.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2016-12-08 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (144 votes). Check out past polls.