SlideShare a Scribd company logo
Variables in Pharo5
ESUG 2015
Marcus Denker
http://www.pharo.org
Everything is an Object
Everything?
Classes, yes.
Methods, yes
But Variables?
Everything is an object?
SmalltalkImage classVarNamed: #CompilerClass
==> returns value
Object binding class
==> Association
Why not an Object?
Globals/ClassVariables
• We are close: bindings are associations
• Add sublass “LiteralVariable”
• Sublasses GlobalVariable, ClassVariable
• Enhance API
Globals/ClassVariables
SmalltalkImage classVariableNamed: #CompilerClass
Object binding class
Globals: Reflective APi
global := SmalltalkImage classVariableNamed:
#CompilerClass
global read
global write: someObject
+ helper methods + compatibility methods
Everything is an object?
• Point instanceVariables
• 5@3 instVarNamed: ‘x’
• 5@3 instVarNamed: ‘y’ put: 6
Why not an Object?
Slots
Point slots
(Point slotNamed: #x) read: (3@4)
(Point slotNamed: #x) write: 7 to: (3@4)
Variables+MetaLink
• Helper methods
• But: can’t we annotate variables directly?
Point assignmentNodes
Variables + Links
• Object binding link: myMetaLink
• (Point slotNamed: #x) link: myMetaLink
(not yet in Pharo5)
Opal Compiler
• Uses RB AST
• Based on Visitors
Text AST
AST
+vars
IR CM
Parser Semantic
Analysis
AST Translator+
IRBuilder
BytecodeBuilder+
Encoder
Opal Compiler
• Name analysis finds the variables
• Code generator can delegate to them
Text AST
AST
+vars
IR CM
Parser Semantic
Analysis
AST Translator+
IRBuilder
BytecodeBuilder+
Encoder
Gobals: code read
• By default compile reflective read
emitValue: aMethodBuilder
aMethodBuilder
pushLiteralVariable: #slot->self;
send: #read
Gobals: code write
• By default compile reflective write
emitStore: aMethodBuilder
| tempName |
tempName := Object new.
aMethodBuilder
addTemp: tempName;
storeTemp: tempName;
popTop;
pushLiteralVariable: #global -> self;
pushTemp: tempName;
send: #write:
Gobals: code write
• ClassVariable and GlobalVariable override
emitStore: methodBuilder
methodBuilder storeIntoLiteralVariable: self.
Same for Slots
• Slot generates reflective read/write
• InstanceVariableSlot overrides for fast instance
access via byte code
What does that mean?
• Slots and Globals are instances of a class
• The compiler delegates code generation to the
variable meta object
• Which means: We can define our own variables!
Class Template
Object subclass: #Point
slots: { #x. #y }
classVariables: { }
category: 'Kernel-BasicObjects'
Class Template
Object subclass: #MyClass
slots: { #x => WeakSlot }
classVariables: { }
category: 'Example'
Examples: DEMO
• Simple Slot
• WeakSlot
• Property Slot
• Boolean
RoadMap
• Pharo3:
• Layout+Slots (hidden), Opal
• Pharo4
• Slots: Monticello support, class template
• Pharo5
• Remove old Compiler/AST
• Slots + Reflectivity: First finished version
RoadMap
• Pharo6:
• Library of useful Slots
• Use e.g. Property Slots in Bloc/Morphic
Future
• Can’t we model bit patterns and bind them to
named virtual slots?
• How to model Array-like layouts better?
Thanks!
• Work of many people…
• special thanks to… Toon Verwaest, Camillo
Bruni, Martin Dias, Stephane Ducasse, Max
Mattone and Camille Teruel
Questions ?

More Related Content

PDF
Reflection in Pharo: Beyond Smalltak
PDF
Reflection in Pharo: Beyond Smalltak
PDF
Dynamically Composing Collection Operations through Collection Promises
PDF
Advanced Reflection in Pharo
PDF
Reflection in Pharo5
PDF
Pharo Status ESUG 2014
PDF
#Pharo Days 2016 Reflectivity
PDF
PharoDAYS 2015: Pharo Status - by Markus Denker
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
Dynamically Composing Collection Operations through Collection Promises
Advanced Reflection in Pharo
Reflection in Pharo5
Pharo Status ESUG 2014
#Pharo Days 2016 Reflectivity
PharoDAYS 2015: Pharo Status - by Markus Denker

What's hot (19)

PDF
#Pharo Days 2016 Data Formats and Protocols
PDF
Lecture: MetaLinks
PPTX
Java 8 concurrency abstractions
PDF
Gatling @ Scala.Io 2013
ODP
How to start using Scala
PDF
Load test REST APIs using gatling
PDF
java8-patterns
PDF
C# 8 in Libraries and Applications
PPTX
Intro to Ruby on Rails
PPTX
PDF
Swift, a quick overview
PPTX
Java 8 New features
PDF
使用.NET构建轻量级分布式框架
PDF
How we migrated Zalando app to Swift3?
PPTX
Top 10 RxJs Operators in Angular
PDF
TypeScript for Java Developers
PDF
The dark side of Akka and the remedy
PDF
Speed geeking-lotusscript
KEY
Advanced Server Integration with Data and Direct
#Pharo Days 2016 Data Formats and Protocols
Lecture: MetaLinks
Java 8 concurrency abstractions
Gatling @ Scala.Io 2013
How to start using Scala
Load test REST APIs using gatling
java8-patterns
C# 8 in Libraries and Applications
Intro to Ruby on Rails
Swift, a quick overview
Java 8 New features
使用.NET构建轻量级分布式框架
How we migrated Zalando app to Swift3?
Top 10 RxJs Operators in Angular
TypeScript for Java Developers
The dark side of Akka and the remedy
Speed geeking-lotusscript
Advanced Server Integration with Data and Direct
Ad

Viewers also liked (8)

PDF
Perfection & Feedback Loops or: why worse is better
KEY
Talk: The Present and Future of Pharo
PDF
Type Feedback for Bytecode Interpreters
PDF
Reflection and Context
PDF
Practical, Pluggable Types
PDF
Pharo Status (from PharoDays 2015)
PDF
How to Contribute to Pharo
DOCX
Examples of reflections
Perfection & Feedback Loops or: why worse is better
Talk: The Present and Future of Pharo
Type Feedback for Bytecode Interpreters
Reflection and Context
Practical, Pluggable Types
Pharo Status (from PharoDays 2015)
How to Contribute to Pharo
Examples of reflections
Ad

Similar to Variables in Pharo5 (20)

PDF
Variables in Pharo
PDF
Slot Composition
PDF
Slot Composition
PDF
Advanced Reflection in Pharo
PDF
Pharo Status ESUG 2014
PDF
Pharo Status ESUG 2014
PDF
First Class Variables as AST Annotations
PDF
First Class Variables as AST Annotations
KEY
Pharo, an innovative and open-source Smalltalk
PPT
PPT
Md02 - Getting Started part-2
PPT
4 - OOP - Taste of Smalltalk (Squeak)
PDF
Pharo: a reflective language A first systematic analysis of reflective APIs
PPT
4 - OOP - Taste of Smalltalk (VisualWorks)
PPT
8 - OOP - Syntax & Messages
PDF
Fluid Class Definitions in Pharo (ESUG 2025)
PPT
Java 5 Features
PDF
Pharo Hands-on: 05 object model
PDF
Prototype-based Programming with JavaScript
PDF
Denker - Pharo: Present and Future - 2009-07-14
Variables in Pharo
Slot Composition
Slot Composition
Advanced Reflection in Pharo
Pharo Status ESUG 2014
Pharo Status ESUG 2014
First Class Variables as AST Annotations
First Class Variables as AST Annotations
Pharo, an innovative and open-source Smalltalk
Md02 - Getting Started part-2
4 - OOP - Taste of Smalltalk (Squeak)
Pharo: a reflective language A first systematic analysis of reflective APIs
4 - OOP - Taste of Smalltalk (VisualWorks)
8 - OOP - Syntax & Messages
Fluid Class Definitions in Pharo (ESUG 2025)
Java 5 Features
Pharo Hands-on: 05 object model
Prototype-based Programming with JavaScript
Denker - Pharo: Present and Future - 2009-07-14

More from Marcus Denker (18)

PDF
Soil And Pharo
PDF
ConstantBlocks in Pharo11
PDF
Demo: Improved DoIt
PDF
Supporting Pharo / Getting Pharo Support
PDF
Lecture: "Advanced Reflection: MetaLinks"
PDF
thisContext in the Debugger
PDF
Lecture. Advanced Reflection: MetaLinks
PDF
Improving code completion for Pharo
PDF
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
PDF
Lecture: Advanced Reflection. MetaLinks
PDF
PHARO IOT
PDF
Open-Source: An Infinite Game
PDF
PharoTechTalk: Contributing to Pharo
PDF
Feedback Loops in Practice
PDF
Pharo6 - ESUG17
PDF
PDF
Pharo Status Fosdem 2015
PDF
Nomads do not build Cathedrals
Soil And Pharo
ConstantBlocks in Pharo11
Demo: Improved DoIt
Supporting Pharo / Getting Pharo Support
Lecture: "Advanced Reflection: MetaLinks"
thisContext in the Debugger
Lecture. Advanced Reflection: MetaLinks
Improving code completion for Pharo
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
Lecture: Advanced Reflection. MetaLinks
PHARO IOT
Open-Source: An Infinite Game
PharoTechTalk: Contributing to Pharo
Feedback Loops in Practice
Pharo6 - ESUG17
Pharo Status Fosdem 2015
Nomads do not build Cathedrals

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
KodekX | Application Modernization Development
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PPTX
Cloud computing and distributed systems.
PDF
Modernizing your data center with Dell and AMD
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Big Data Technologies - Introduction.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
20250228 LYD VKU AI Blended-Learning.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
KodekX | Application Modernization Development
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Cloud computing and distributed systems.
Modernizing your data center with Dell and AMD
NewMind AI Monthly Chronicles - July 2025
Big Data Technologies - Introduction.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation theory and applications.pdf

Variables in Pharo5