SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Smalltalk Blocks and Closures
Origins and Evolution
Juan Francisco Escalada
I. Origin and Evolution
II. Anatomy of a Block
III. Anonymous Function = Block?
IV. Possibilities
I. Origin and Evolution
LISP
● Invented in 1958
● S-expression language
● Dynamic Scope
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
Scheme
● Invented during the 1970s at MIT
● Functional programming language
● Lexical Scope
● Introduction of Closures
> (define (f x) (lambda (y) (+ x y)))
> (define increaseByFive (f 5))
> (define increaseBySeven (f 7))
> (increaseByFive 5)
10
> (increaseBySeven 5)
12
Another example
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
The problem
The problem
II. Anatomy of a Block
Object Representation of a Block on Pharo/Squeak
Compiled Method
Context
Block Closure
Sender
Context
Receiver
Method
Creating a Block
● Instantiation
● Definition
● Evaluation
Redefinitions
Self Receiver
Implicit
Return
Sender
Explicit
Return (^)
Method Return Context
III. Anonymous Function = Block?
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
✔
✔
✔
✔
✔
✔
✔
✔
✔
✔
✔
✗
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.
IV. Exploring Possibilities
Recursive Functions
| fibonacci |
fibonacci := [:number |
number <= 1
ifTrue: [number]
ifFalse: [ (fibonacci value: number - 1)
+ (fibonacci value: number - 2)]
].
fibonacci value: 13. “-> 233”
High Order Functions
| foldr multiplyAll |
foldr:= [:base :recursion | [:collection |
collection isEmpty
ifTrue: [base]
ifFalse: [
recursion
value: collection first
value: ((foldr value: base value: recursion)
value: collection allButFirst) ] ]
].
multiplyAll := foldr value: 1 value: [:number :result | result * number].
multiplyAll value: (5 to: 10). “-> 151200”
| anObjectFactory anObject |
anObjectFactory := [ :anInstanceVariable | | methods |
methods := Dictionary new
at: #plus put: [:anArgument| anArgument + anInstanceVariable ];
at: #minus put: [:anArgument| anArgument - anInstanceVariable ];
yourself.
[ :aSelector :anArgument |
(methods at: aSelector ifAbsent:['I do not Understand ', aSelector])
value: anArgument ]
].
anObject := anObjectFactory value: 2.
anObject value: #plus value: 3. "-> 5"
anObject value: #sum value: 3. "-> 'I do not Understand sum'"
Representing Objects with Blocks
Conclusion
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.
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.
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.
Thanks for Coming!
jf.escalada92@gmail.com
@JuanEscaladaQuestions?

Contenu connexe

Tendances

Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by DivyaDivya Kumari
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by DivyaDivya Kumari
 
Introduction to programming with dependent types in Scala
Introduction to programming with dependent types in ScalaIntroduction to programming with dependent types in Scala
Introduction to programming with dependent types in ScalaDmytro Mitin
 
function in c
function in cfunction in c
function in csubam3
 
Functional Programming and Ruby
Functional Programming and RubyFunctional Programming and Ruby
Functional Programming and RubyPat Shaughnessy
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1Mook Prapasson
 
JavaScript: Patterns, Part 1
JavaScript: Patterns, Part  1JavaScript: Patterns, Part  1
JavaScript: Patterns, Part 1Chris Farrell
 
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and LearnPaul Irwin
 
CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4昀 李
 
Numpy Meetup 07/02/2013
Numpy Meetup 07/02/2013Numpy Meetup 07/02/2013
Numpy Meetup 07/02/2013Francesco
 
2.1 Recap From Day One
2.1 Recap From Day One2.1 Recap From Day One
2.1 Recap From Day Oneretronym
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programmingchriseidhof
 
xlwings - Connecting Python with Excel
xlwings - Connecting Python with Excelxlwings - Connecting Python with Excel
xlwings - Connecting Python with Excelxlwings
 

Tendances (20)

Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
 
Ast 09
Ast 09Ast 09
Ast 09
 
Slides
SlidesSlides
Slides
 
Introduction to programming with dependent types in Scala
Introduction to programming with dependent types in ScalaIntroduction to programming with dependent types in Scala
Introduction to programming with dependent types in Scala
 
function in c
function in cfunction in c
function in c
 
Ps installedsoftware
Ps installedsoftwarePs installedsoftware
Ps installedsoftware
 
Class & sub class
Class & sub classClass & sub class
Class & sub class
 
Functional Programming and Ruby
Functional Programming and RubyFunctional Programming and Ruby
Functional Programming and Ruby
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
 
Dynamic allocation
Dynamic allocationDynamic allocation
Dynamic allocation
 
JavaScript: Patterns, Part 1
JavaScript: Patterns, Part  1JavaScript: Patterns, Part  1
JavaScript: Patterns, Part 1
 
Modern C++ Lunch and Learn
Modern C++ Lunch and LearnModern C++ Lunch and Learn
Modern C++ Lunch and Learn
 
CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4
 
Scheme 核心概念(一)
Scheme 核心概念(一)Scheme 核心概念(一)
Scheme 核心概念(一)
 
Numpy Meetup 07/02/2013
Numpy Meetup 07/02/2013Numpy Meetup 07/02/2013
Numpy Meetup 07/02/2013
 
2.1 Recap From Day One
2.1 Recap From Day One2.1 Recap From Day One
2.1 Recap From Day One
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
xlwings - Connecting Python with Excel
xlwings - Connecting Python with Excelxlwings - Connecting Python with Excel
xlwings - Connecting Python with Excel
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 

Similaire à Smalltalk blocks and closures origin and evolution by Juan Escalada

From Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksFrom Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksSeniorDevOnly
 
High Wizardry in the Land of Scala
High Wizardry in the Land of ScalaHigh Wizardry in the Land of Scala
High Wizardry in the Land of Scaladjspiewak
 
Lecture One: Fundamental of Computational Economics
Lecture One: Fundamental of Computational EconomicsLecture One: Fundamental of Computational Economics
Lecture One: Fundamental of Computational EconomicsXi Hao Li
 
[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8Alonso Torres
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoMuhammad Abdullah
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesTomer Gabel
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos3Pillar Global
 
Monadologie
MonadologieMonadologie
Monadologieleague
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...GeeksLab Odessa
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With ScalaKnoldus Inc.
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Mattersromanandreg
 
[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using Haskell[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using HaskellFunctional Thursday
 

Similaire à Smalltalk blocks and closures origin and evolution by Juan Escalada (20)

Clojure Linters
Clojure LintersClojure Linters
Clojure Linters
 
Manual specialization
Manual specializationManual specialization
Manual specialization
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
From Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksFrom Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risks
 
Scala by Luc Duponcheel
Scala by Luc DuponcheelScala by Luc Duponcheel
Scala by Luc Duponcheel
 
High Wizardry in the Land of Scala
High Wizardry in the Land of ScalaHigh Wizardry in the Land of Scala
High Wizardry in the Land of Scala
 
Scala: A brief tutorial
Scala: A brief tutorialScala: A brief tutorial
Scala: A brief tutorial
 
Lecture One: Fundamental of Computational Economics
Lecture One: Fundamental of Computational EconomicsLecture One: Fundamental of Computational Economics
Lecture One: Fundamental of Computational Economics
 
[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8[Codemotion 2015] patrones de diseño con java8
[Codemotion 2015] patrones de diseño con java8
 
Introduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demoIntroduction to kotlin + spring boot demo
Introduction to kotlin + spring boot demo
 
Scala Back to Basics: Type Classes
Scala Back to Basics: Type ClassesScala Back to Basics: Type Classes
Scala Back to Basics: Type Classes
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos
 
Monadologie
MonadologieMonadologie
Monadologie
 
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...
 
Functional Programming With Scala
Functional Programming With ScalaFunctional Programming With Scala
Functional Programming With Scala
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
Why Haskell Matters
Why Haskell MattersWhy Haskell Matters
Why Haskell Matters
 
[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using Haskell[FLOLAC'14][scm] Functional Programming Using Haskell
[FLOLAC'14][scm] Functional Programming Using Haskell
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 

Plus de FAST

Threads, Critical Sections, and Termination
Threads, Critical Sections, and TerminationThreads, Critical Sections, and Termination
Threads, Critical Sections, and TerminationFAST
 
OOP with Smalltalk
OOP with SmalltalkOOP with Smalltalk
OOP with SmalltalkFAST
 
Powerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming LanguagesPowerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming LanguagesFAST
 
Constructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden EngineConstructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden EngineFAST
 
Demystifying the creation of coding tools
Demystifying the creation of coding toolsDemystifying the creation of coding tools
Demystifying the creation of coding toolsFAST
 
Application Starter: the entry point for your application
Application Starter: the entry point for your applicationApplication Starter: the entry point for your application
Application Starter: the entry point for your applicationFAST
 
Improving the Pharo VM
Improving the Pharo VMImproving the Pharo VM
Improving the Pharo VMFAST
 
What is (not) Pharo 8?
What is (not) Pharo 8?What is (not) Pharo 8?
What is (not) Pharo 8?FAST
 
Stargate: an interstellar journey to RESTful APIs
Stargate: an interstellar journey to RESTful APIsStargate: an interstellar journey to RESTful APIs
Stargate: an interstellar journey to RESTful APIsFAST
 
Opening Smalltalks 2019
Opening Smalltalks 2019Opening Smalltalks 2019
Opening Smalltalks 2019FAST
 
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção JrSmalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção JrFAST
 
Adaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção JrAdaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção JrFAST
 
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...FAST
 
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...FAST
 
Improving VASmalltalk deployment, availability and scalability with Docker by...
Improving VASmalltalk deployment, availability and scalability with Docker by...Improving VASmalltalk deployment, availability and scalability with Docker by...
Improving VASmalltalk deployment, availability and scalability with Docker by...FAST
 
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the worldVASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the worldFAST
 
Hands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting WorkshopHands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting WorkshopFAST
 
Live typing: Update and what's next by Hernan Wilkinson
Live typing: Update and what's next by Hernan WilkinsonLive typing: Update and what's next by Hernan Wilkinson
Live typing: Update and what's next by Hernan WilkinsonFAST
 
Enhanced Email Protocol Framework for VAST by Seth Berman
Enhanced Email Protocol Framework for VAST by Seth BermanEnhanced Email Protocol Framework for VAST by Seth Berman
Enhanced Email Protocol Framework for VAST by Seth BermanFAST
 
VA Smalltalk Product Update by Seth Berman
VA Smalltalk Product Update by Seth BermanVA Smalltalk Product Update by Seth Berman
VA Smalltalk Product Update by Seth BermanFAST
 

Plus de FAST (20)

Threads, Critical Sections, and Termination
Threads, Critical Sections, and TerminationThreads, Critical Sections, and Termination
Threads, Critical Sections, and Termination
 
OOP with Smalltalk
OOP with SmalltalkOOP with Smalltalk
OOP with Smalltalk
 
Powerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming LanguagesPowerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming Languages
 
Constructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden EngineConstructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden Engine
 
Demystifying the creation of coding tools
Demystifying the creation of coding toolsDemystifying the creation of coding tools
Demystifying the creation of coding tools
 
Application Starter: the entry point for your application
Application Starter: the entry point for your applicationApplication Starter: the entry point for your application
Application Starter: the entry point for your application
 
Improving the Pharo VM
Improving the Pharo VMImproving the Pharo VM
Improving the Pharo VM
 
What is (not) Pharo 8?
What is (not) Pharo 8?What is (not) Pharo 8?
What is (not) Pharo 8?
 
Stargate: an interstellar journey to RESTful APIs
Stargate: an interstellar journey to RESTful APIsStargate: an interstellar journey to RESTful APIs
Stargate: an interstellar journey to RESTful APIs
 
Opening Smalltalks 2019
Opening Smalltalks 2019Opening Smalltalks 2019
Opening Smalltalks 2019
 
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção JrSmalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
 
Adaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção JrAdaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção Jr
 
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
 
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
 
Improving VASmalltalk deployment, availability and scalability with Docker by...
Improving VASmalltalk deployment, availability and scalability with Docker by...Improving VASmalltalk deployment, availability and scalability with Docker by...
Improving VASmalltalk deployment, availability and scalability with Docker by...
 
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the worldVASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
 
Hands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting WorkshopHands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting Workshop
 
Live typing: Update and what's next by Hernan Wilkinson
Live typing: Update and what's next by Hernan WilkinsonLive typing: Update and what's next by Hernan Wilkinson
Live typing: Update and what's next by Hernan Wilkinson
 
Enhanced Email Protocol Framework for VAST by Seth Berman
Enhanced Email Protocol Framework for VAST by Seth BermanEnhanced Email Protocol Framework for VAST by Seth Berman
Enhanced Email Protocol Framework for VAST by Seth Berman
 
VA Smalltalk Product Update by Seth Berman
VA Smalltalk Product Update by Seth BermanVA Smalltalk Product Update by Seth Berman
VA Smalltalk Product Update by Seth Berman
 

Dernier

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Smalltalk blocks and closures origin and evolution by Juan Escalada

  • 1. Smalltalk Blocks and Closures Origins and Evolution
  • 3. I. Origin and Evolution II. Anatomy of a Block III. Anonymous Function = Block? IV. Possibilities
  • 4. I. Origin and Evolution
  • 5. LISP ● Invented in 1958 ● S-expression language ● Dynamic Scope
  • 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
  • 12. II. Anatomy of a Block
  • 13. Object Representation of a Block on Pharo/Squeak Compiled Method Context Block Closure
  • 15. Creating a Block ● Instantiation ● Definition ● Evaluation
  • 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.
  • 21. Recursive Functions | fibonacci | fibonacci := [:number | number <= 1 ifTrue: [number] ifFalse: [ (fibonacci value: number - 1) + (fibonacci value: number - 2)] ]. fibonacci value: 13. “-> 233”
  • 22. High Order Functions | foldr multiplyAll | foldr:= [:base :recursion | [:collection | collection isEmpty ifTrue: [base] ifFalse: [ recursion value: collection first value: ((foldr value: base value: recursion) value: collection allButFirst) ] ] ]. multiplyAll := foldr value: 1 value: [:number :result | result * number]. multiplyAll value: (5 to: 10). “-> 151200”
  • 23. | anObjectFactory anObject | anObjectFactory := [ :anInstanceVariable | | methods | methods := Dictionary new at: #plus put: [:anArgument| anArgument + anInstanceVariable ]; at: #minus put: [:anArgument| anArgument - anInstanceVariable ]; yourself. [ :aSelector :anArgument | (methods at: aSelector ifAbsent:['I do not Understand ', aSelector]) value: anArgument ] ]. anObject := anObjectFactory value: 2. anObject value: #plus value: 3. "-> 5" anObject value: #sum value: 3. "-> 'I do not Understand sum'" Representing Objects with Blocks
  • 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.