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

Pharo 11: A stabilization release
Pharo 11: A stabilization releasePharo 11: A stabilization release
Pharo 11: A stabilization releaseESUG
 
FreeCAD OpenFOAM Workbenchセットアップ方法と課題
FreeCAD OpenFOAM Workbenchセットアップ方法と課題FreeCAD OpenFOAM Workbenchセットアップ方法と課題
FreeCAD OpenFOAM Workbenchセットアップ方法と課題murai1972
 
#MSDEVMTL Introduction à #SonarQube
#MSDEVMTL Introduction à #SonarQube#MSDEVMTL Introduction à #SonarQube
#MSDEVMTL Introduction à #SonarQubeVincent Biret
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3Angel Boy
 
SonarQube - Should I Stay or Should I Go ?
SonarQube - Should I Stay or Should I Go ? SonarQube - Should I Stay or Should I Go ?
SonarQube - Should I Stay or Should I Go ? Geeks Anonymes
 
Track code quality with SonarQube - short version
Track code quality with SonarQube - short versionTrack code quality with SonarQube - short version
Track code quality with SonarQube - short versionDmytro Patserkovskyi
 
Advantages and disadvantages of a monorepo
Advantages and disadvantages of a monorepoAdvantages and disadvantages of a monorepo
Advantages and disadvantages of a monorepoIanDavidson56
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) Johnny Sung
 
SonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualitySonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualityLarry Nung
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for DocumentationAnne Gentle
 
Continuous Inspection of Code Quality: SonarQube
Continuous Inspection of Code Quality: SonarQubeContinuous Inspection of Code Quality: SonarQube
Continuous Inspection of Code Quality: SonarQubeEmre Dündar
 
Edureka-DevOps-Ebook.pdf
Edureka-DevOps-Ebook.pdfEdureka-DevOps-Ebook.pdf
Edureka-DevOps-Ebook.pdfrelekarsushant
 
Code Quality Lightning Talk
Code Quality Lightning TalkCode Quality Lightning Talk
Code Quality Lightning TalkJonathan Gregory
 

What's hot (20)

Pharo 11: A stabilization release
Pharo 11: A stabilization releasePharo 11: A stabilization release
Pharo 11: A stabilization release
 
FreeCAD OpenFOAM Workbenchセットアップ方法と課題
FreeCAD OpenFOAM Workbenchセットアップ方法と課題FreeCAD OpenFOAM Workbenchセットアップ方法と課題
FreeCAD OpenFOAM Workbenchセットアップ方法と課題
 
#MSDEVMTL Introduction à #SonarQube
#MSDEVMTL Introduction à #SonarQube#MSDEVMTL Introduction à #SonarQube
#MSDEVMTL Introduction à #SonarQube
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3
 
SonarQube - Should I Stay or Should I Go ?
SonarQube - Should I Stay or Should I Go ? SonarQube - Should I Stay or Should I Go ?
SonarQube - Should I Stay or Should I Go ?
 
Track code quality with SonarQube - short version
Track code quality with SonarQube - short versionTrack code quality with SonarQube - short version
Track code quality with SonarQube - short version
 
Advantages and disadvantages of a monorepo
Advantages and disadvantages of a monorepoAdvantages and disadvantages of a monorepo
Advantages and disadvantages of a monorepo
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot Framework
 
Refactoring
RefactoringRefactoring
Refactoring
 
Understanding Monorepos
Understanding MonoreposUnderstanding Monorepos
Understanding Monorepos
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
SonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualitySonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code Quality
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
 
Continuous Inspection of Code Quality: SonarQube
Continuous Inspection of Code Quality: SonarQubeContinuous Inspection of Code Quality: SonarQube
Continuous Inspection of Code Quality: SonarQube
 
Git
GitGit
Git
 
Edureka-DevOps-Ebook.pdf
Edureka-DevOps-Ebook.pdfEdureka-DevOps-Ebook.pdf
Edureka-DevOps-Ebook.pdf
 
Code Quality Lightning Talk
Code Quality Lightning TalkCode Quality Lightning Talk
Code Quality Lightning Talk
 
Flutter Bootcamp
Flutter BootcampFlutter Bootcamp
Flutter Bootcamp
 
DevOps for beginners
DevOps for beginnersDevOps for beginners
DevOps for beginners
 

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

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 

Recently uploaded (20)

The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 

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