[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inner methods
> From owner-self@self.stanford.edu Sun Oct 27 14:10:36 1991
> Return-Path: <jecel@lsi12.lsi.usp.br>
> Date: Sat, 26 Oct 91 14:28:33 EDT
> To: self-interest@self.stanford.edu
> Subject: inner methods
> Content-Length: 545
> X-Lines: 18
>
> I can't see what is the purpose of inner methods. For example, in :
>
> _AddSlotsIfAbsent: ( | imTests = () | ).
>
> imTests _Define: ( |
> test1: a And: b = ( a * b * b ).
> test2: a And: b = ( ( a * b ) * b ).
> | ).
>
> Both test1 and test2 do exactly the same thing, but test2's structure
> at the bytecode level is more complex. If fact, for inner methods with
> no local slots, I believe you can always "inline" the inner method's
> bytecodes.
>
> Since inner methods with local slots are rare ( I think ), do we
> really need them ?
>
> - Jecel
>
Well, yes and no.
It's nice to know that you can walk up to any method, see:
. . . <some-message> ...
and replace it with
... (|t| doAnythingFirst. t: <some-message>. doAnythingAfter: t. t) ...
This might be nice for debugging, for example.
Also, inner methods make the language more elegant (to our eyes).
Of course, they do waste space.
And many languages (C, PASCAL, FORTRAN, COBOL) get along fine without them.
Dave