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
Thinkful - Intro to JavaScript
PDF
Dynamically Composing Collection Operations through Collection Promises
ODP
Getting started with typescript and angular 2
PDF
Advanced Reflection in Pharo
PDF
Intro to javascript (6:19)
PDF
Intro to JavaScript - Thinkful LA, June 2017
PPTX
AngularConf2015
Reflection in Pharo: Beyond Smalltak
Thinkful - Intro to JavaScript
Dynamically Composing Collection Operations through Collection Promises
Getting started with typescript and angular 2
Advanced Reflection in Pharo
Intro to javascript (6:19)
Intro to JavaScript - Thinkful LA, June 2017
AngularConf2015

What's hot (20)

PDF
Conscious Decoupling - Lone Star PHP
PPTX
JavaScript operators
PPTX
JavaScript Basics
PPTX
Type script - advanced usage and practices
ODP
Shapeless- Generic programming for Scala
PPT
Web development basics (Part-7)
PPT
Web development basics (Part-5)
PPTX
TypeScript Modules
PPTX
TypeScript
PDF
Swift Micro-services and AWS Technologies
PPT
Web development basics (Part-4)
PPTX
Introducing type script
PDF
Model with actors and implement with Akka
PDF
TypeScript: coding JavaScript without the pain
PDF
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
PDF
Intro to javascript (4 week)
PDF
Reflection in Pharo5
PDF
Swift, a quick overview
PDF
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
Conscious Decoupling - Lone Star PHP
JavaScript operators
JavaScript Basics
Type script - advanced usage and practices
Shapeless- Generic programming for Scala
Web development basics (Part-7)
Web development basics (Part-5)
TypeScript Modules
TypeScript
Swift Micro-services and AWS Technologies
Web development basics (Part-4)
Introducing type script
Model with actors and implement with Akka
TypeScript: coding JavaScript without the pain
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
Intro to javascript (4 week)
Reflection in Pharo5
Swift, a quick overview
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
Ad

Viewers also liked (9)

PDF
The Pharo Evolution
PDF
Painting with Roassal2
PDF
Concurrency in Smalltalk -- Beyond Threads
PDF
Behavioral Reflection in Pharo
PDF
Towards Well Planned Code Cities
PDF
Scratching the itch, making Scratch for the Raspberry Pie
PDF
Toward a Platform for Visual Debugging
PDF
Smalltalk-driven GUI Testing
PDF
Pharo
The Pharo Evolution
Painting with Roassal2
Concurrency in Smalltalk -- Beyond Threads
Behavioral Reflection in Pharo
Towards Well Planned Code Cities
Scratching the itch, making Scratch for the Raspberry Pie
Toward a Platform for Visual Debugging
Smalltalk-driven GUI Testing
Pharo
Ad

Similar to First class Variables in Pharo (20)

PDF
10 Groovy Little JavaScript Tips
PDF
Fluid Class Definitions in Pharo (ESUG 2025)
PPTX
Java script
PDF
Slot Composition
PDF
Slot Composition
PDF
XAML/C# to HTML/JS
PDF
Refactoring
ZIP
Cappuccino - A Javascript Application Framework
PDF
Variables in Pharo
PDF
Everything-as-code - A polyglot adventure
PDF
Everything-as-code. A polyglot adventure. #DevoxxPL
PDF
Glorp Tutorial Guide
PPTX
Java script basics
PDF
Handlebars & Require JS
PPTX
Introduction to JavaScript
PDF
Raffaele Rialdi
PDF
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
PDF
Spring Day | Spring and Scala | Eberhard Wolff
PPTX
JavaScript Fundamentals & JQuery
PDF
Awesome html with ujs, jQuery and coffeescript
10 Groovy Little JavaScript Tips
Fluid Class Definitions in Pharo (ESUG 2025)
Java script
Slot Composition
Slot Composition
XAML/C# to HTML/JS
Refactoring
Cappuccino - A Javascript Application Framework
Variables in Pharo
Everything-as-code - A polyglot adventure
Everything-as-code. A polyglot adventure. #DevoxxPL
Glorp Tutorial Guide
Java script basics
Handlebars & Require JS
Introduction to JavaScript
Raffaele Rialdi
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
Spring Day | Spring and Scala | Eberhard Wolff
JavaScript Fundamentals & JQuery
Awesome html with ujs, jQuery and coffeescript

More from ESUG (20)

PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
PDF
Directing Generative AI for Pharo Documentation
PDF
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
PDF
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
PDF
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
PDF
Analysing Python Machine Learning Notebooks with Moose
PDF
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
PDF
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
PDF
Package-Aware Approach for Repository-Level Code Completion in Pharo
PDF
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
PDF
An Analysis of Inline Method Refactoring
PDF
Identification of unnecessary object allocations using static escape analysis
PDF
Control flow-sensitive optimizations In the Druid Meta-Compiler
PDF
Clean Blocks (IWST 2025, Gdansk, Poland)
PDF
Encoding for Objects Matters (IWST 2025)
PDF
Challenges of Transpiling Smalltalk to JavaScript
PDF
Immersive experiences: what Pharo users do!
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
PDF
Cavrois - an Organic Window Management (ESUG 2025)
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
Micromaid: A simple Mermaid-like chart generator for Pharo
Directing Generative AI for Pharo Documentation
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
Analysing Python Machine Learning Notebooks with Moose
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
Package-Aware Approach for Repository-Level Code Completion in Pharo
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
An Analysis of Inline Method Refactoring
Identification of unnecessary object allocations using static escape analysis
Control flow-sensitive optimizations In the Druid Meta-Compiler
Clean Blocks (IWST 2025, Gdansk, Poland)
Encoding for Objects Matters (IWST 2025)
Challenges of Transpiling Smalltalk to JavaScript
Immersive experiences: what Pharo users do!
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
Cavrois - an Organic Window Management (ESUG 2025)

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
DOCX
The AUB Centre for AI in Media Proposal.docx
PPT
Teaching material agriculture food technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Machine learning based COVID-19 study performance prediction
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation_ Review paper, used for researhc scholars
The AUB Centre for AI in Media Proposal.docx
Teaching material agriculture food technology
Understanding_Digital_Forensics_Presentation.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Machine learning based COVID-19 study performance prediction
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Electronic commerce courselecture one. Pdf
Building Integrated photovoltaic BIPV_UPV.pdf

First class Variables in Pharo