Style

Bijan Parsia bparsia at email.unc.edu
Fri Jun 18 16:14:48 UTC 1999



--On Friday, June 18, 1999, 10:18 AM -0500 "Ralph E. Johnson"
<johnson at cs.uiuc.edu> wrote:

> At 3:43 AM 6/18/99, Peter William Lount wrote:
>> Obviously I have a different style then some of you. This is fine. Your
>> style is fine. There is not any one right style.  I would hope that all
>> his methods are not this large and I would recommend that he see if he
>> can refactor the method in some way to shorten it but ultimately it's
>> his call and not mine. It's a judgement call for him to make and
>> Smalltalk should not enforce some arbirtary limit to satisfy the
>> "temporary variable police".
> 
> I am writing a reply to this paragraph because it is so important.
> It is also wrong in a very important sense.

[snip] 

Sure it's his judgement call. And, as was pointed out, he can get it wrong
:) The real issue is whether there's any real need to *support* that
judgement call.

> Peter is also wrong about the reason the VM limits the number
> of variables.  All VMs limit the number, the question is what
> the limit should be.  It is easier to implement VMs with smaller
> numbers.  The VM designers looked at real code, decided it didn't
> require large numbers, so made a decision that allowed them to
> make programs smaller and faster.

I'd like to point out that simplicity of the vm/compiler code is an
important consideration. If 99% of the methods are under the Squeak temp
var limit, I'd rather have the few methods which have a "natural" number of
temps which exceed that limit be obscured than to complicate whatever code
causes the limit (espeically if there are also general speed tradeoffs).

I'm not *asserting* that this is the case. Heck if there's a simple tweak
that expands the limit, I don't think I have much space for objecting. But
I doubt it's like that.

We'd have to pay the price somewhere. Notice that both consitutacies are
rather small (i.e., the many temps folks and the kernal hackers), but I
don't think they're of equal weight (i.e., it's more important to have a
simple kernal than have many temped methods).

>  I have been programming in
> Smalltalk for 15 years, and have never written a method that
> the compiler wouldn't accept because it had too many temporaries.
> However, I once wrote a program that generated code that the
> compiler wouldn't accept!  That was how I found out there were
> limits.

This is probably one of the few cases where one might reasonably expect
long icky methods with lost of temps (i.e., generated code not intended for
direct human consumption). But there a lot of tricks (e.g., reusing temps)
that aren't as palatable elsewhere come into play.

[snip]
 
> So, the limit is small because Smalltalk programmers don't
> use lots of variables.  It is not small to prevent people
> from using lots of variables.

One might think of the prevention as a "happy side effect". 

Cheers,
Bijan Parsia





More information about the Squeak-dev mailing list