A mathematical foundation of reflexion?

Massimo Dentico m.dentico@teseo.it
Wed, 12 Jan 2000 22:21:26 +0100


Laurent Martelli wrote:
> 
> >>>>> "John" == John Carter <cyent@mweb.co.za> writes:
> 
>   John> I think Joy lays bare that special something about Forth and
>   John> Postscript.  The homomorphism between syntatic concatenation
>   John> and functional composition. If that homomorphism exists, then
>   John> reasoning about the program becomes very much easier, and if
>   John> reasoning becomes easier it is much easier to write bug free
>   John> programs.
>
> I'm not so sure. I think that the absence of named parameters can make
> it difficult to understand programs.
> 
> --
> Laurent Martelli
> martelli@iie.cnam.fr

Not if used correctly.  The following articles  refer to  Forth, a
prototipical programming environment based on anonymous parameters
(stack);  it's  an interactive  interpreter/compiler:  you  type a
definition and immediatly  the environment compile it  and you can
test it. The cited articles report the ideas of Charles Moore, the
inventor of Forth,  a perfectionist  and  minimalist.  If  you are
familiar with  programs written  in Forth,  probably you  complain
of a bad programming style, like long word(procedure) definitions.
In reading these definitions you often lost the stack picture. But
this is *not* the intended use of the language  (at least from his
author).

"1x Forth"
- http://www.ultratechnology.com/1xforth.htm
==================================================================
[...]

Forth is highly factored code.   I don't know anything else to say
except  that Forth  is definitions.  If you have  a lot  of  small
definitions  you are writing  Forth.   In order  to write a lot of
small definitions you have to have a stack.

[...]

You factor.  You factor, you factor, you factor and you throw away
everything that isn't being used, that isn't justified.
["Factor definitions until most definitions are one or two lines."
he says]

[...]

What is  a definition?  Well classically  a definition  was  colon
something, and words, and end of definition somewhere.

: some ~~~ ;

I always tried to explain this in the sense of this [a word] is an
abbreviation, whatever this string of words you have here that you
use frequently you have here you give it a name and you can use it
more conveniently.  But its not exactly an abbreviation because it
can have  a parameter  perhaps or two.  And that is a problem with
programmers,  perhaps  a problem with  all programmers;   too many
input parameters  to a routine.  Look at some 'C' programs  and it
gets ludicrous.  Everything  in the program is passed  through the
calling sequence and that is dumb.

A Forth  word should  not have more  than one  or  two  arguments.
This stack  which people have  so much trouble manipulating should
never be more than three or four deep.  [so avoiding  troubles  to
interpret a stack picture]

[...]
==================================================================

A truly interesting reading is also:

"Thoughtful Programming"
- http://www.ultratechnology.com/forth.htm

==================================================================
- http://www.ultratechnology.com/forth2.htm#swb

[...]

Stacks  are great  (for Forth) so use them.  Chuck has said "Don't
use locals."  You have a stack for data, this is Forth, locals are
for a whole different picture. 

[...]

- http://www.ultratechnology.com/forth2.htm#metric

[remember that a colon definition is a procedure difinition]
As a metric  I did  some  analysis  of  code  examples  Chuck  has
provided.  The numbers I find most interesting is  that the length
of the average  colon definition  is 44 characters.  The length of
the longest  colon definition  was 70 characters.  This is  a sign
that he has factored, factored, factored.  How big are the average
definitions in your code?  Smaller definitions are easier to code,
easier to test, etc.

[...]
==================================================================

-- 
Massimo Dentico