[583] in Coldmud discussion meeting

root meeting help first first in chain previous in chain previous next last

Re: use of test value in a while loop

daemon@ATHENA.MIT.EDU (Sat Nov 12 22:55:28 1994 )

Date: Sat, 12 Nov 1994 22:49:43 -0500 (EST)
From: James C Deikun <jcdst10+@pitt.edu>
To: Robert de Forest <deforest@netcom.com>
Cc: coldstuff@MIT.EDU
In-Reply-To: <199411120114.RAA17273@netcom3.netcom.com>

> There has been a raging debate on this list on the following uglyness:
> 
> @program thing.example
>  var test_val;
> 
>  test_val = .test();
>  while (test_val) {
>    .use_of_test_val(test_val);
>    test_val = .test();
>  }
> .

And ugly it surely is.

> A wise programmer just gave me a clue. He said the above could be re-written
>  in the following way:
> 
> @program thing.loop_code
>  arg test_val;
>  
>  test_val && .use_of_test_val(test_val);
>  return test_val;
> .
> 
> @program thing.example
>  while (.loop_code(.test()));
> .

I suppose it could.

> It costs a method call and gives you an abstraction and simplification.

I'm not sure where you get this 'abstraction and simplification' idea.
I found this form harder to understnad than the original.  It's also
longer, and takes twice as much effort to list.  It breaks the loop code
which is probably internally conceptually connected into two highly
separated parts, uses up a chunk of namespace for no obvious benefit,
and quickly becomes tremendously awkward in the likely case that the
loop code involves the use fo several local variables.  If it also
changes them, things become impossible, or at least horrifyingly ugly.

> With
>  .loop_code marked private/local/"search for method on definer() only", would
>  not be too expenseive.

In the case of a simple loop, the only type in which this method is much
use, I could see the cost of the method call being significant even if it
was local.

> I hearby revoke any vote I made in favor of a new loop stucture, and vote
>  strongly against do {} while {} or any of the other propsals.

I'm not sure why this is in this message; do {} while() {} wouldn't
simplify this loop all that much anyway; however I still find

@program object.example
 var test_val;

 do
   test_val = .test();
 while (test_val)
   .use_of_test_value(test_val);
.

to be cleaner and shorter than either of the previous presentations, and
only difficult to understand if it is unfamiliar.  Maybe there is a more
'self-explanatory' syntax for such loops, but it'd still hardly be the
least immediately clear aspect of ColdC.

> I no longer accept the 'let the programmer decide' argument for design because
>  Cold is a social language in that it begs for group work. That being the case,
>  its design should be such that bad code design is not possible or very hard
>  to use.

Glad to see you've come around on the higher-level issues, at least.

--
James Deikun (James & splat@JHM & BlueMOOn)