Temporary variables

Randal L. Schwartz merlyn at stonehenge.com
Thu Jun 17 20:17:47 UTC 1999


>>>>> "Pierre" == Pierre Roy <pierre at limbo.create.ucsb.edu> writes:

Pierre> Let me give another example.  I have implemented a constraint
Pierre> satisfaction system.  A constraint satisfaction problem
Pierre> consists of a set of variables and a set of relationships (the
Pierre> constraints) defined over the variables.  In many classical
Pierre> problems, there are more than 20 variables (20 variables is a
Pierre> small problem).

I still disagree.  At some point, you'll probably want to do similar
or identical things to all the variables.  At that point, you'll
either have to write repeated code, or put them *into* a collection!
Even the way you describe them sounds like a collection to me.

Pierre>   And in some cases, like the cryptogram I send
Pierre> in my previous post, there is a standard way to state the
Pierre> problem in which the variables are not put into collections.

You keep mixing up domain space and implementation space.  A variable
in domain space is not necessarily a temp in Smalltalk space!

Pierre> Of course, one cas always use collections to reduce the number
Pierre> of variables needed, but in these cases it would be
Pierre> particularly awkward and would lead to a hardly readable code.

If you write two lines of code that look similar, except one has
temporary "f" in it and one has temporary "g" in it, I DO NOT WANT TO
MAINTAIN YOUR CODE.  That doesn't look "readable" to me.  And the
sample code you sent me was FULL of that stuff.  It was about the most
unreadable Smalltalk I've ever seen, except for the ST80 image's
Paragraph-something>>update-something which was two or three pages
long. :)

Again, go get Beck's "Smalltalk Best Practice Patterns".  I learned a
lot from that book, and have been applying most of the ideas even to
my Perl coding.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn at stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn at teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me





More information about the Squeak-dev mailing list