Here is a tiny proposal to make Smalltalk more functional

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Here is a tiny proposal to make Smalltalk more functional

Kjell Godo
Here is a proposal to make Smalltalk more 
functional.

If a Block B is never assigned to any variable in
a Method M and B is not returned by M and B is evaluated 
by M
 
then B should be inlined by the Compiler as a way
of allocating and assigning immutable local variables
which can be part of a more functional local style of 
Smalltalk programming.

Functional is good. Look at Haskell Scala Java F# 
Ocaml lisp etc which are all going functional. Look at 
category theory which is the theory of function composition
and function combination. It is good to base programming
on math. Look at Smalltalk Traits which are state free.
Smalltalk can be more functional.

No value Activation should be done by ( B value.. )
in M at runtime but only immutable local variable 
assignments followed by immutable variable accesses.

Here is an example of a local tail recursive function
using only immutable variables :

  [ :recurse | recurse value: input value: recurse 
  ] value:[ :input1 :recurse |
( input1 message1 )
ifTrue:[ input1 message2 ]
ifFalse:[ 
recurse value:( input1 message3 )
value: recurse ] ]

Category Theory for programmers by Bartosz Milewski

Thank you 
Kjell E Godø