SlideShare a Scribd company logo
1 of 45
Download to read offline
Functional Smalltalk
Dave Mason
Toronto Metropolitan University
©2022 Dave Mason
Value
I’m going to start with a quote from Kent Beck
Value
Software creates value 2 ways:
What it does today
What new things we can make it do tomorrow
Value
Software creates value 2 ways:
What it does today
What new things we can make it do tomorrow
Value
Software creates value 2 ways:
What it does today
What new things we can make it do tomorrow
Value
Smalltalk creates value 2 ways:
What it does today
What new things we can make it do tomorrow
Functional Smalltalk
Smalltalk already has many functional features
extensions by syntax
extensions by class
Functional Smalltalk
Smalltalk already has many functional features
extensions by syntax
extensions by class
Syntax: Functional Programming
Smalltalk has always had blocks - needed full closures
CompileWithCompose in Pharo-Functional repo
leverages class-bounded alternative compiler
just syntactic sugar - more succinct
all are upward compatible as they are currently syntax errors
Syntax: Functional Programming
Smalltalk has always had blocks - needed full closures
CompileWithCompose in Pharo-Functional repo
leverages class-bounded alternative compiler
just syntactic sugar - more succinct
all are upward compatible as they are currently syntax errors
Syntax: Functional Programming
Smalltalk has always had blocks - needed full closures
CompileWithCompose in Pharo-Functional repo
leverages class-bounded alternative compiler
just syntactic sugar - more succinct
all are upward compatible as they are currently syntax errors
Syntax: Functional Programming
Smalltalk has always had blocks - needed full closures
CompileWithCompose in Pharo-Functional repo
leverages class-bounded alternative compiler
just syntactic sugar - more succinct
all are upward compatible as they are currently syntax errors
Syntax: Functional Programming
Smalltalk has always had blocks - needed full closures
CompileWithCompose in Pharo-Functional repo
leverages class-bounded alternative compiler
just syntactic sugar - more succinct
all are upward compatible as they are currently syntax errors
Compose/pipe/parrot operator
very convenient to pass result of one expression to another
without parentheses
particularly convenient in PharoJS for e.g. D3
Compose/pipe/parrot operator
very convenient to pass result of one expression to another
without parentheses
particularly convenient in PharoJS for e.g. D3
1 foo
2 " s e l f new foo >>> 42 "
3 ↑ 17 negated
4 :> min: -53
5 :> abs
6 :> < 100
7 :> and: [ 4 > 2 ]
8 :> and: [ 5 < 10 ]
9 :> ifTrue: [ 42 ] ifFalse: [ 99 ]
Compose/pipe/parrot operator
very convenient to pass result of one expression to another
without parentheses
particularly convenient in PharoJS for e.g. D3
1 foo
2 " s e l f new foo >>> 42 "
3 ↑ 17 negated
4 :> min: -53
5 :> abs
6 :> < 100
7 :> and: [ 4 > 2 ]
8 :> and: [ 5 < 10 ]
9 :> ifTrue: [ 42 ] ifFalse: [ 99 ]
... Compose/pipe/parrot operator
The precedence is the same as cascade, so you can intermix them
and could say something like:
1 x := OrderedCollection new
2 add: 42;
3 add: 17;
4 yourself
5 :> collect: #negated
6 :> add: 35;
7 add: 99;
8 yourself
9 :> with: #(1 2 3 4) collect: [:l :r| l+r ]
10 :> max
... Compose/pipe/parrot operator
If you don’t want to use the alternate compiler (and get the :> syntax)
PharoFunctional also provides a chain method on Object that
supports chaining using cascades (unfortunately quite a bit slower
because it requires a DNU and perform for each chained message):
1 foo
2 " s e l f new foo >>> 42 "
3 ↑ 17 chain
4 negated
5 ; min: -53
6 ; abs
7 ; < 100
8 ; and: [ 4 > 2 ]
9 ; and: [ 5 < 10 ]
10 ; ifTrue: [ 42 ] ifFalse: [ 99 ]
Point-free programming style
popular style of functional programming
composing functions to build up operations with implicit
parameters
various “combinators” that recognize patterns in these
compositions
in Smalltalk this is composing symbols and blocks
e.g.
1 isPalindrome := #reverse <| > #= .
2 isPalindrome value: ’madam’
Point-free programming style
popular style of functional programming
composing functions to build up operations with implicit
parameters
various “combinators” that recognize patterns in these
compositions
in Smalltalk this is composing symbols and blocks
e.g.
1 isPalindrome := #reverse <| > #= .
2 isPalindrome value: ’madam’
Point-free programming style
popular style of functional programming
composing functions to build up operations with implicit
parameters
various “combinators” that recognize patterns in these
compositions
in Smalltalk this is composing symbols and blocks
e.g.
1 isPalindrome := #reverse <| > #= .
2 isPalindrome value: ’madam’
Point-free programming style
popular style of functional programming
composing functions to build up operations with implicit
parameters
various “combinators” that recognize patterns in these
compositions
in Smalltalk this is composing symbols and blocks
e.g.
1 isPalindrome := #reverse <| > #= .
2 isPalindrome value: ’madam’
Point-free programming style
popular style of functional programming
composing functions to build up operations with implicit
parameters
various “combinators” that recognize patterns in these
compositions
in Smalltalk this is composing symbols and blocks
e.g.
1 isPalindrome := #reverse <| > #= .
2 isPalindrome value: ’madam’
Expressions as unary or binary messages
To use point-free style, it is very convenient to have a more succinct
syntax for applying them
1 x (...)
2 x (...) + y
3 x (...): y
4 x (#sort <| > #=)
Converts to.
1 ([...] value: x)
2 ([...] value: x) + y
3 ([...] value: x value: y)
4 ((#sort <| > #=) value: x)
Blocks as unary or binary messages
You can do the same with unary or binary blocks. Because we know
the arity of blocks the trailing : isn’t used for block operators
1 x [:w| ...]
2 x [:w:z| ...] y
becomes
1 ([:w| ...] value: x)
2 ([:w:z| ...] value: x value: y)
Initializing local variables at point of declaration
Even in functional languages where mutation is possible, it is rarely
used. Instead programming is by a sequence of definitions, which
always have a value. I personally very much miss this in Smalltalk.
1 | w x := 42. y = x+5. z a |
is legal, but
1 | x := 42. y = x+5. z = 17 |
isn’t.
Collection literals
Arrays have a literal syntax {1 . 2 . 3}, but other collections don’t.
This extension recognizes :className immediately after the { and
translates, e.g.
1 {:Set 3 . 4 . 5 . 3}
2 {:Dictionary #a->1 . #b->2}
3 {:Set 1 . 2 . 3 . 4 . 5 . 6 . 7}
to
1 Set with: 3 with: 4 with: 5 with: 3
2 Dictionary with: #a->1 with: #b->2
3 Set withAll: {1 . 2 . 3 . 4 . 5 . 6 . 7}
Destructuring collections
There isn’t a convenient way to return multiple values from a method,
or even to extract multiple values from a collection. For example:
1 :| a b c | := some-collection
destructures the 3 elements of a SequenceableCollection or would
extract the value of keys #a #b etc. if it was a Dictionary, with anything
else being a runtime error. This is conveniently done by converting that
to:
1 ([:temp|
2 a := temp firstNamed: #a.
3 b := temp secondNamed: #b.
4 c := temp thirdNamed: #c.
5 temp] value: some-collection)
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Classes: Functional Programming
PharoFunctional adds several new classes and a variety of extension
methods to facilitate functional programming.
curry: and @@
value:, value:value: and cull, etc. for Symbol
map:, map:map: for BlockClosure and Symbol
<*> and other combinators for BlockClosure and Symbol
nilOr:, emptyOrNilOr:
Slice, Pair and Tuple, ZippedCollection
zip:, >===<
iota
many algorithms on collections: rotate:, slide:, product,
allEqual, unique, isUnique, groupByRunsEqual:,
groupByRunsTrue:
Demo
Using CompileWithCompose
1 Metacello new
2 baseline: ’PharoFunctional’;
3 repository: ’github://dvmason/Pharo-Functional:ma
4 load: #compiler
Then for any class heirarchy, add a trait:
1 RBScannerTest subclass: #ComposeExampleTest
2 uses: ComposeSyntax
3 instanceVariableNames: ’’
4 classVariableNames: ’’
5 package: ’CompileWithCompose-Tests’
Or, on the class-side define the following method:
1 compilerClass
2 " Answer a compiler c l a s s a p p r o p r i a t e f o r source
3 ↑ ComposeCompiler
You can use this second approach if you want to add it to the entire
image (including in playgrounds), by defining this in Object class.
Conclusions
Smalltalk already has the fundamentals for functional
programming
some simple syntactic suger can make it a lot more pleasant
I would love it if some of these became mainstream (with no
backward compatibility issues)
in the meantime, anyone can add this to their Pharo
the compiler tweaks are not hard for other Smalltalks to implement
Conclusions
Smalltalk already has the fundamentals for functional
programming
some simple syntactic suger can make it a lot more pleasant
I would love it if some of these became mainstream (with no
backward compatibility issues)
in the meantime, anyone can add this to their Pharo
the compiler tweaks are not hard for other Smalltalks to implement
Conclusions
Smalltalk already has the fundamentals for functional
programming
some simple syntactic suger can make it a lot more pleasant
I would love it if some of these became mainstream (with no
backward compatibility issues)
in the meantime, anyone can add this to their Pharo
the compiler tweaks are not hard for other Smalltalks to implement
Conclusions
Smalltalk already has the fundamentals for functional
programming
some simple syntactic suger can make it a lot more pleasant
I would love it if some of these became mainstream (with no
backward compatibility issues)
in the meantime, anyone can add this to their Pharo
the compiler tweaks are not hard for other Smalltalks to implement
Conclusions
Smalltalk already has the fundamentals for functional
programming
some simple syntactic suger can make it a lot more pleasant
I would love it if some of these became mainstream (with no
backward compatibility issues)
in the meantime, anyone can add this to their Pharo
the compiler tweaks are not hard for other Smalltalks to implement
Questions?
@DrDaveMason dmason@ryerson.ca
https://github.com/dvmason/Pharo-Functional

More Related Content

What's hot

re:mobidyc the overview
re:mobidyc the overviewre:mobidyc the overview
re:mobidyc the overviewESUG
 
Towards Object-centric Time-traveling Debuggers
 Towards Object-centric Time-traveling Debuggers Towards Object-centric Time-traveling Debuggers
Towards Object-centric Time-traveling DebuggersESUG
 
GemStone Update
GemStone Update GemStone Update
GemStone Update ESUG
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoFAST
 
Pharo 11: A stabilization release
Pharo 11: A stabilization releasePharo 11: A stabilization release
Pharo 11: A stabilization releaseESUG
 
GemStone Update 2023
GemStone Update 2023GemStone Update 2023
GemStone Update 2023ESUG
 
PharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript ApplicationsPharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript ApplicationsESUG
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyArnaud Bouchez
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of ScalaMartin Odersky
 
Pwning in c++ (basic)
Pwning in c++ (basic)Pwning in c++ (basic)
Pwning in c++ (basic)Angel Boy
 
Play with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit TechniquePlay with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit TechniqueAngel Boy
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeAngel Boy
 
Linux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend ProgramingLinux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend ProgramingAngel Boy
 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksMarcus Denker
 
Capabilities for Resources and Effects
Capabilities for Resources and EffectsCapabilities for Resources and Effects
Capabilities for Resources and EffectsMartin Odersky
 
初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎Will Huang
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 
Combinator Pattern in Java 8
Combinator Pattern in Java 8Combinator Pattern in Java 8
Combinator Pattern in Java 8Gregor Trefs
 
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...joaomatosf_
 

What's hot (20)

re:mobidyc the overview
re:mobidyc the overviewre:mobidyc the overview
re:mobidyc the overview
 
Towards Object-centric Time-traveling Debuggers
 Towards Object-centric Time-traveling Debuggers Towards Object-centric Time-traveling Debuggers
Towards Object-centric Time-traveling Debuggers
 
GemStone Update
GemStone Update GemStone Update
GemStone Update
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
 
Pharo 11: A stabilization release
Pharo 11: A stabilization releasePharo 11: A stabilization release
Pharo 11: A stabilization release
 
GemStone Update 2023
GemStone Update 2023GemStone Update 2023
GemStone Update 2023
 
PharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript ApplicationsPharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript Applications
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 Cryptography
 
The Evolution of Scala
The Evolution of ScalaThe Evolution of Scala
The Evolution of Scala
 
Pwning in c++ (basic)
Pwning in c++ (basic)Pwning in c++ (basic)
Pwning in c++ (basic)
 
Play with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit TechniquePlay with FILE Structure - Yet Another Binary Exploit Technique
Play with FILE Structure - Yet Another Binary Exploit Technique
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
Linux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend ProgramingLinux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend Programing
 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
 
Capabilities for Resources and Effects
Capabilities for Resources and EffectsCapabilities for Resources and Effects
Capabilities for Resources and Effects
 
初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎初學者都該了解的 HTTP 通訊協定基礎
初學者都該了解的 HTTP 通訊協定基礎
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Combinator Pattern in Java 8
Combinator Pattern in Java 8Combinator Pattern in Java 8
Combinator Pattern in Java 8
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
An Overview of Deserialization Vulnerabilities in the Java Virtual Machine (J...
 

Similar to Functional Smalltalk

Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perlmegakott
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoMatt Stine
 
The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...PVS-Studio
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answersAkash Gawali
 
Matlab for diploma students(1)
Matlab for diploma students(1)Matlab for diploma students(1)
Matlab for diploma students(1)Retheesh Raj
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesEelco Visser
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4Richard Jones
 
EKON 12 Closures Coding
EKON 12 Closures CodingEKON 12 Closures Coding
EKON 12 Closures CodingMax Kleiner
 
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Puppet
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...bobmcwhirter
 
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomMore on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomValeriy Kravchuk
 
Sinatra and friends
Sinatra and friendsSinatra and friends
Sinatra and friendsJiang Wu
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpMichael Stal
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpMichael Stal
 

Similar to Functional Smalltalk (20)

Aspect-oriented programming in Perl
Aspect-oriented programming in PerlAspect-oriented programming in Perl
Aspect-oriented programming in Perl
 
Swift, swiftly
Swift, swiftlySwift, swiftly
Swift, swiftly
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
 
The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...
 
New features in Ruby 2.5
New features in Ruby 2.5New features in Ruby 2.5
New features in Ruby 2.5
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers
 
Matlab for diploma students(1)
Matlab for diploma students(1)Matlab for diploma students(1)
Matlab for diploma students(1)
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4
 
EKON 12 Closures Coding
EKON 12 Closures CodingEKON 12 Closures Coding
EKON 12 Closures Coding
 
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
Andy On Closures
Andy On ClosuresAndy On Closures
Andy On Closures
 
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB DevroomMore on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
More on bpftrace for MariaDB DBAs and Developers - FOSDEM 2022 MariaDB Devroom
 
Php
PhpPhp
Php
 
Best practices tekx
Best practices tekxBest practices tekx
Best practices tekx
 
Sinatra and friends
Sinatra and friendsSinatra and friends
Sinatra and friends
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharp
 
Qcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharpQcon2011 functions rockpresentation_f_sharp
Qcon2011 functions rockpresentation_f_sharp
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingESUG
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in PharoESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapESUG
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsESUG
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector TuningESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FutureESUG
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerESUG
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing ScoreESUG
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptESUG
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 

Recently uploaded (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

Functional Smalltalk

  • 1. Functional Smalltalk Dave Mason Toronto Metropolitan University ©2022 Dave Mason
  • 2. Value I’m going to start with a quote from Kent Beck
  • 3. Value Software creates value 2 ways: What it does today What new things we can make it do tomorrow
  • 4. Value Software creates value 2 ways: What it does today What new things we can make it do tomorrow
  • 5. Value Software creates value 2 ways: What it does today What new things we can make it do tomorrow
  • 6. Value Smalltalk creates value 2 ways: What it does today What new things we can make it do tomorrow
  • 7. Functional Smalltalk Smalltalk already has many functional features extensions by syntax extensions by class
  • 8. Functional Smalltalk Smalltalk already has many functional features extensions by syntax extensions by class
  • 9. Syntax: Functional Programming Smalltalk has always had blocks - needed full closures CompileWithCompose in Pharo-Functional repo leverages class-bounded alternative compiler just syntactic sugar - more succinct all are upward compatible as they are currently syntax errors
  • 10. Syntax: Functional Programming Smalltalk has always had blocks - needed full closures CompileWithCompose in Pharo-Functional repo leverages class-bounded alternative compiler just syntactic sugar - more succinct all are upward compatible as they are currently syntax errors
  • 11. Syntax: Functional Programming Smalltalk has always had blocks - needed full closures CompileWithCompose in Pharo-Functional repo leverages class-bounded alternative compiler just syntactic sugar - more succinct all are upward compatible as they are currently syntax errors
  • 12. Syntax: Functional Programming Smalltalk has always had blocks - needed full closures CompileWithCompose in Pharo-Functional repo leverages class-bounded alternative compiler just syntactic sugar - more succinct all are upward compatible as they are currently syntax errors
  • 13. Syntax: Functional Programming Smalltalk has always had blocks - needed full closures CompileWithCompose in Pharo-Functional repo leverages class-bounded alternative compiler just syntactic sugar - more succinct all are upward compatible as they are currently syntax errors
  • 14. Compose/pipe/parrot operator very convenient to pass result of one expression to another without parentheses particularly convenient in PharoJS for e.g. D3
  • 15. Compose/pipe/parrot operator very convenient to pass result of one expression to another without parentheses particularly convenient in PharoJS for e.g. D3 1 foo 2 " s e l f new foo >>> 42 " 3 ↑ 17 negated 4 :> min: -53 5 :> abs 6 :> < 100 7 :> and: [ 4 > 2 ] 8 :> and: [ 5 < 10 ] 9 :> ifTrue: [ 42 ] ifFalse: [ 99 ]
  • 16. Compose/pipe/parrot operator very convenient to pass result of one expression to another without parentheses particularly convenient in PharoJS for e.g. D3 1 foo 2 " s e l f new foo >>> 42 " 3 ↑ 17 negated 4 :> min: -53 5 :> abs 6 :> < 100 7 :> and: [ 4 > 2 ] 8 :> and: [ 5 < 10 ] 9 :> ifTrue: [ 42 ] ifFalse: [ 99 ]
  • 17. ... Compose/pipe/parrot operator The precedence is the same as cascade, so you can intermix them and could say something like: 1 x := OrderedCollection new 2 add: 42; 3 add: 17; 4 yourself 5 :> collect: #negated 6 :> add: 35; 7 add: 99; 8 yourself 9 :> with: #(1 2 3 4) collect: [:l :r| l+r ] 10 :> max
  • 18. ... Compose/pipe/parrot operator If you don’t want to use the alternate compiler (and get the :> syntax) PharoFunctional also provides a chain method on Object that supports chaining using cascades (unfortunately quite a bit slower because it requires a DNU and perform for each chained message): 1 foo 2 " s e l f new foo >>> 42 " 3 ↑ 17 chain 4 negated 5 ; min: -53 6 ; abs 7 ; < 100 8 ; and: [ 4 > 2 ] 9 ; and: [ 5 < 10 ] 10 ; ifTrue: [ 42 ] ifFalse: [ 99 ]
  • 19. Point-free programming style popular style of functional programming composing functions to build up operations with implicit parameters various “combinators” that recognize patterns in these compositions in Smalltalk this is composing symbols and blocks e.g. 1 isPalindrome := #reverse <| > #= . 2 isPalindrome value: ’madam’
  • 20. Point-free programming style popular style of functional programming composing functions to build up operations with implicit parameters various “combinators” that recognize patterns in these compositions in Smalltalk this is composing symbols and blocks e.g. 1 isPalindrome := #reverse <| > #= . 2 isPalindrome value: ’madam’
  • 21. Point-free programming style popular style of functional programming composing functions to build up operations with implicit parameters various “combinators” that recognize patterns in these compositions in Smalltalk this is composing symbols and blocks e.g. 1 isPalindrome := #reverse <| > #= . 2 isPalindrome value: ’madam’
  • 22. Point-free programming style popular style of functional programming composing functions to build up operations with implicit parameters various “combinators” that recognize patterns in these compositions in Smalltalk this is composing symbols and blocks e.g. 1 isPalindrome := #reverse <| > #= . 2 isPalindrome value: ’madam’
  • 23. Point-free programming style popular style of functional programming composing functions to build up operations with implicit parameters various “combinators” that recognize patterns in these compositions in Smalltalk this is composing symbols and blocks e.g. 1 isPalindrome := #reverse <| > #= . 2 isPalindrome value: ’madam’
  • 24. Expressions as unary or binary messages To use point-free style, it is very convenient to have a more succinct syntax for applying them 1 x (...) 2 x (...) + y 3 x (...): y 4 x (#sort <| > #=) Converts to. 1 ([...] value: x) 2 ([...] value: x) + y 3 ([...] value: x value: y) 4 ((#sort <| > #=) value: x)
  • 25. Blocks as unary or binary messages You can do the same with unary or binary blocks. Because we know the arity of blocks the trailing : isn’t used for block operators 1 x [:w| ...] 2 x [:w:z| ...] y becomes 1 ([:w| ...] value: x) 2 ([:w:z| ...] value: x value: y)
  • 26. Initializing local variables at point of declaration Even in functional languages where mutation is possible, it is rarely used. Instead programming is by a sequence of definitions, which always have a value. I personally very much miss this in Smalltalk. 1 | w x := 42. y = x+5. z a | is legal, but 1 | x := 42. y = x+5. z = 17 | isn’t.
  • 27. Collection literals Arrays have a literal syntax {1 . 2 . 3}, but other collections don’t. This extension recognizes :className immediately after the { and translates, e.g. 1 {:Set 3 . 4 . 5 . 3} 2 {:Dictionary #a->1 . #b->2} 3 {:Set 1 . 2 . 3 . 4 . 5 . 6 . 7} to 1 Set with: 3 with: 4 with: 5 with: 3 2 Dictionary with: #a->1 with: #b->2 3 Set withAll: {1 . 2 . 3 . 4 . 5 . 6 . 7}
  • 28. Destructuring collections There isn’t a convenient way to return multiple values from a method, or even to extract multiple values from a collection. For example: 1 :| a b c | := some-collection destructures the 3 elements of a SequenceableCollection or would extract the value of keys #a #b etc. if it was a Dictionary, with anything else being a runtime error. This is conveniently done by converting that to: 1 ([:temp| 2 a := temp firstNamed: #a. 3 b := temp secondNamed: #b. 4 c := temp thirdNamed: #c. 5 temp] value: some-collection)
  • 29. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 30. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 31. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 32. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 33. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 34. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 35. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 36. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 37. Classes: Functional Programming PharoFunctional adds several new classes and a variety of extension methods to facilitate functional programming. curry: and @@ value:, value:value: and cull, etc. for Symbol map:, map:map: for BlockClosure and Symbol <*> and other combinators for BlockClosure and Symbol nilOr:, emptyOrNilOr: Slice, Pair and Tuple, ZippedCollection zip:, >===< iota many algorithms on collections: rotate:, slide:, product, allEqual, unique, isUnique, groupByRunsEqual:, groupByRunsTrue:
  • 38. Demo
  • 39. Using CompileWithCompose 1 Metacello new 2 baseline: ’PharoFunctional’; 3 repository: ’github://dvmason/Pharo-Functional:ma 4 load: #compiler Then for any class heirarchy, add a trait: 1 RBScannerTest subclass: #ComposeExampleTest 2 uses: ComposeSyntax 3 instanceVariableNames: ’’ 4 classVariableNames: ’’ 5 package: ’CompileWithCompose-Tests’ Or, on the class-side define the following method: 1 compilerClass 2 " Answer a compiler c l a s s a p p r o p r i a t e f o r source 3 ↑ ComposeCompiler You can use this second approach if you want to add it to the entire image (including in playgrounds), by defining this in Object class.
  • 40. Conclusions Smalltalk already has the fundamentals for functional programming some simple syntactic suger can make it a lot more pleasant I would love it if some of these became mainstream (with no backward compatibility issues) in the meantime, anyone can add this to their Pharo the compiler tweaks are not hard for other Smalltalks to implement
  • 41. Conclusions Smalltalk already has the fundamentals for functional programming some simple syntactic suger can make it a lot more pleasant I would love it if some of these became mainstream (with no backward compatibility issues) in the meantime, anyone can add this to their Pharo the compiler tweaks are not hard for other Smalltalks to implement
  • 42. Conclusions Smalltalk already has the fundamentals for functional programming some simple syntactic suger can make it a lot more pleasant I would love it if some of these became mainstream (with no backward compatibility issues) in the meantime, anyone can add this to their Pharo the compiler tweaks are not hard for other Smalltalks to implement
  • 43. Conclusions Smalltalk already has the fundamentals for functional programming some simple syntactic suger can make it a lot more pleasant I would love it if some of these became mainstream (with no backward compatibility issues) in the meantime, anyone can add this to their Pharo the compiler tweaks are not hard for other Smalltalks to implement
  • 44. Conclusions Smalltalk already has the fundamentals for functional programming some simple syntactic suger can make it a lot more pleasant I would love it if some of these became mainstream (with no backward compatibility issues) in the meantime, anyone can add this to their Pharo the compiler tweaks are not hard for other Smalltalks to implement