Even though there probably isn't a Smalltalk developer who doesn't use Block on a daily basis,
it's not common knowledge that they are based on the idea of Anonymous Functions,
nor that their Closures' origins can be traced back to Scheme.
The idea of this talk is to analyze the origin of this tool that defined Smalltalk, it's evolution until it became the full closure that we know today, and have a better idea of the potential advantages it provides.
6. CL-USER> (defvar x -99)
X
CL-USER> (defun getx () x)
GETX
CL-USER> (let ((x 1))
(getx))
1
CL-USER> (getx)
-99
A small example
7. Scheme
● Invented during the 1970s at MIT
● Functional programming language
● Lexical Scope
● Introduction of Closures
8. > (define (f x) (lambda (y) (+ x y)))
> (define increaseByFive (f 5))
> (define increaseBySeven (f 7))
> (increaseByFive 5)
10
> (increaseBySeven 5)
12
Another example
9. Smalltalk-80
● First version to be made publicly available in 1980
● Introduced Blocks and Closures
● Did not allow Reentrance on Blocks
● Lacked own local environment
18. Anonymous
Functions
Blocks
High Order
Can be an Argument
Can be a Result
Nesting
Allows named calls
Allows anonymous calls
Non-local
Variables
Has Closure
Allows Partial Application
Characteristics
✔
✔
✔
✔
✔
✔
✔
✔
✔
✔
✔
✗
19. Why aren’t Smalltalk Blocks curried?
● It’s not necessary for the normal use we have for blocks.
● We have the “security” that blocks will not be evaluated with less arguments than
necessary.
25. Functional vs. Object Oriented
● Realizing that some concepts are not exclusive to one paradigm.
● Understanding why things as Closures are necessary on both views.
● Thinking of paradigms more like points of view rather than opposites.
26. Importance of Understanding your Tools
Exploiting their potential
● Understanding what they can actually do.
● Being able to take advantage of their characteristics.
● Finding novel uses that were not considered before.
27. Iterative and Incremental evolution
● A design as Smalltalk Closures is the product of several iterations over the years.
● A good design ideas transcends the limits of a Language or Paradigm.
● There’s always room to keep working on better solutions to the same problem.