IronSmalltalk
  August 24th 2011
   Todor Todorov
IronSmalltalk
  Smalltalk for the
 Microsoft .Net DLR
Agenda
•   History
•   Motivation and Background
•   Microsoft .Net DLR
•   Message Sends and CallSites
•   CallSite Binders
•   Expression Trees
•   Code Pipeline
•   Polymorphic Inline Caching
•   Conclusion
•   Extras / Bonus

24 August 2011        Todor Todorov   3 / 111
Smalltalk 1980
Smalltalk 1980
Smalltalk 1981
Smalltalk 2011
Smalltalk 2005
The World Today
The World Today
Smalltalking
 since 1998
  Todor Todorov
Business
Applications
Microsoft
.Net Platform
Costly vs. Free?
Commodity!
Goal
• X3J20 Compliant Smalltalk

• First Class Member of the
  DLR Family

• Easy interop. with .Net

• Decent Performance
Personal
Challenge
.NET DLR
.NET DLR
.NET DLR
Message Send
Message Send
Communication
Message Send

Transcript show:
   'Hello, Edinburgh!'.
Message Send
Transcript show: 'Hello, Edinburgh!'.

TranscriptStream >> show: anObject

self
       nextPutAll: anObject asString;
       endEntry.
Method Lookup
Transcript show: 'Hello, Edinburgh!'.

TranscriptStream >> show: anObject

self
       nextPutAll: anObject asString;
       endEntry.
Call Site
Transcript show: 'Hello, Edinburgh!'.

call1 := Message receiver: Transcript
     selector: #show:
     arguments: #('Hello, Edinb… ').
call1 evaluate.
Call Site
Transcript show: 'Hello, Edinburgh!'.

call1 := CallSite receiver: Transcript
     selector: #show:
     arguments: #('Hello, Edinb… ').
call1 evaluate.
Call Site
Transcript show: 'Hello, Edinburgh!'.

call1 := CallSite selector: #show:.

call1
   evaluateWithReceiver: Transcript
   andArgs: #('Hello, Edinburgh').
Call Site Binders
Transcript show: 'Hello, Edinburgh!'.

call1 := CallSite onBinder:
     (Binder selector: #show:).

call1
   evaluateWithReceiver: Transcript
   andArgs: #('Hello, Edinburgh').
Call Site Binders
Binder >> bindFor: aReceiver
     arguments: anArray

^BindingRule for:
    (aReceiver compiledMethodAt:
         #show).
Dynamic Objects
 Reflective Objects
Call Site Binders
Binder >> bindFor: aReceiver
     arguments: anArray

^BindingRule for:
    (aReceiver compiledMethodAt:
         #show).
Call Site Binders
Binder >> bindFor: aReceiver
     arguments: anArray

^aReceiver bindEvaluateFor: self
    arguments: anArray.
Call Site Binders
Object >> bindEvaluateFor: aBinder
     arguments: anArray

^BindingRule for:
    (self compiledMethodAt:
          aBinder selector).

    ” or return whatever it wants! ”
Call Site Binders
  … receiver can’t help us, then …

fallbackBindInvokeFor: aReceiver
     arguments: anArray

^BindingRule for:
    … some compiled method …
Expression Trees
Expression Trees
Abstract Semantic Tree
Expression Trees
Abstract Semantic Tree
Abstract Syntax Tree
Expression Trees
Abstract Semantic Tree
Abstract Syntax Tree
Expression trees model code
Expression Trees
Abstract Semantic Tree
Abstract Syntax Tree
Expression trees model code
Expressions are used to
represent the implementation
of certain code or logic
Expression Trees
signString

   ^self < 0
      ifTrue: [ 'Negative' ]
      ifFalse: [ 'Positive' ].
Expression Trees
signString

^Expression
   condition: (Expression
        lowerThan: self value: 0)
   true: 'Negative'
   false: 'Positive'.
Expression Trees
signString

selfArg := Expression parameter: 'self'.

^Expression
     condition: (Expression
           lowerThan: selfArg
           value: (Expression constant: 0))
     true: (Expression constant: 'Negative')
     false: (Expression constant: 'Positive').
Expression Trees
TranscriptStream>>show: anObject


self
       nextPutAll: anObject.
Expression Trees
self
       nextPutAll: anObject.

selfArg := Expression parameter: 'self'.
arg1 := Expression parameter: 'anObject'.

^Expression
     dynamic: (Binder selector: #nextPutAll:)
     receiver: selfArg
     arguments: (Array with: arg1).
Expression Trees
Binder >> bindFor: aReceiver
     arguments: anArray

^BindingRule for:
    (aReceiver compiledMethodAt:
         #nextPutAll).
Expression Trees
Binder >> bindFor: aReceiver
     arguments: anArray

^BindingRule expression: (Expression
      dynamic: (Binder selector: #nextPutAll:)
      receiver: aReceiver expression
      arguments: (Array
            with: anArray first expression).
Code Pipeline
Code Pipeline
Smalltalk Sources
Code Pipeline
Smalltalk Sources            Smalltalk
                               AST




          Smalltalk Parser
Code Pipeline
Smalltalk Sources            Smalltalk               Expression
                               AST                      Tree




                                    Smalltalk JIT-
          Smalltalk Parser
                                     Compiler
Code Pipeline
Smalltalk Sources            Smalltalk               Expression              MSIL
                               AST                      Tree               (Bytecode)




                                    Smalltalk JIT-            DLR / Linq
          Smalltalk Parser
                                     Compiler                 Compiler
Code Pipeline
Smalltalk Sources            Smalltalk               Expression              MSIL
                                                                                                     Machine Code
                               AST                      Tree               (Bytecode)




                                    Smalltalk JIT-            DLR / Linq               .NET CLR
          Smalltalk Parser
                                     Compiler                 Compiler              (JIT Compiler)
Polymorphic
Inline Caching
Caching
Transcript show: 'Hello, Edinburgh!'.

call1 := CallSite onBinder:
     (Binder selector: #show:).

call1
   evaluateWithReceiver: Transcript
   andArgs: #('Hello, Edinburgh').
Caching
Binder >> bindFor: aReceiver
       arguments: anArray

method := aReceiver value compiledMethodAt: #show:.

” … magic … to generate expression from method … ”

^BindingRule expression: (Expression
      dynamic: (Binder selector: #nextPutAll:)
      receiver: aReceiver expression
      arguments: (Array
             with: anArray first expression).
Caching
Transcript show: 'Hello, Edinburgh!'.

call1 := CallSite onBinder:
     (Binder selector: #show:).

call1
   evaluateWithReceiver: Transcript
   andArgs: #('Hello, Edinburgh').
Caching
Binder >> bindFor: aReceiver
       arguments: anArray

method := aReceiver value compiledMethodAt: #show:.

” … magic … to generate expression from method … ”


^BindingRule expression: ” … expression … ”
     restriction: [ :obj |
           obj class = TranscriptStream ].
Caching
Transcript show: 'Hello, Edinburgh!'.

call1 := CallSite onBinder:
     (Binder selector: #show:).

call1
   evaluateWithReceiver: Transcript
   andArgs: #('Hello, Edinburgh').
Restrictions
• Restrictions can be more complex
  •   For example, instance specific or object
      version specific
• Restrictions determine the
  polymorphism of objects

• Restrictions are the key to
  polymorphic inline caching!
The Cache
•   3 Levels of Caching:
•   Level 0 : Rule for last call
•   Level 1 : Last 10 rules
•   Level 2 : 100 rules, shares
    across similar call sites
.NET DLR
Common Vocabulary
• None Defined
• De-Facto, the .Net class library
• We aim at reusing the common
  classes
  – Example: System.Char => Character
• Not everything maps easily, but most
  do
  – Example: System.String ~= String
Demo
Summary
Components
                                     Hosting




                             Interchange Installer




IC Encoder        AST JIT Compiler                    DefinitionInstaller




                                                     Runtime
       Compiler                          Core                  IC JitCompiler




                                     Common
Hosting
Windows Process

  .Net AppDomain            .Net AppDomain

    DLR Script Scope          Smalltalk Runtime

      Smalltalk (Runtime)

                              Smalltalk Runtime
      Ruby / Python



    Smalltalk Runtime         DLR Script Scope
Specifics
Symbols
Strings
Smalltalk Process
#sender
#respondsTo:
Events
Object Space
No   Object Space Reflection
No   #allInstances
No   #allReferences
No   #become:



But #behaveLike: is possible!
Debugger inspection is possible.
Major Tech Companies
Good News
Unicode
Multi Threaded
Large Class Library
Web-Hostable
MIT License
Near Future
Generics
Class Library Importer
     (or auto-integration)
Finish Version 1.0
Write Tests (…)
Future
GUI Integration (WinForms + WPF)
SubSystems
(Interactive) Debugger
Visual Studio Integration
Mixins
SubSystems / Namespaces
Instance Specific Behavior
Questions




http://ironsmalltalk.codeplex.com/
   mailto:todor@scientia.dk
Callbacks
                        List showItems:
                             #( 'TT' 'ST' ).




Workspace >> evaluate
Smalltalk >> run
Callbacks
                        List >> showItems: anArray

                         “ AddItems(anArray, self) ”

                             <Windows API>



List >> showItems:
Workspace >> evaluate
Smalltalk >> run
Callbacks
                        List.AddItems(string[] keys,
                              dynamic stList)
                        {
                              for(i=0; i<…;i++)
                                    this.AddItem(
                                          keys[i],
List.AddItems()                            stList);
List >> showItems:      }
Workspace >> evaluate
Smalltalk >> run
Callbacks
                        List.AddItem(string[] keys,
                              dynamic stList)
                        {
                              string text = stList.
                                    .GetItemText(key);
List.AddItem()
List.AddItems()              ” …somehow add it… ”
List >> showItems:      }
Workspace >> evaluate
Smalltalk >> run
Callbacks
                        List >> getItemText:
                              aString

                             ^self itemTexts
List >> getItemText:               at: aString.
List.AddItem()
List.AddItems()
List >> showItems:
Workspace >> evaluate
Smalltalk >> run
Callbacks
                        .Net 4.0 has the dynamic
                        keyword used for invoking
                        method on dynamic objects.


List >> getItemText:    IronSmalltalk objects can
List.AddItem()
                        transparently be used by any
                        DLR aware language.
List.AddItems()
List >> showItems:
Workspace >> evaluate
Smalltalk >> run
Callbacks
                        Native Name: GetItemText

                        List >> getItemText:
                              aString
List >> getItemText:
List.AddItem()
List.AddItems()         The native name is the
List >> showItems:      method name (selector) that
Workspace >> evaluate
                        is exposed to the other DLR
                        languages.
Smalltalk >> run
Exceptions
                        [ Transcript show:
                             'Hello, Edinburgh!' ]
                             on: Error do: [ … ].




Workspace >> evaluate
Smalltalk >> run
Exceptions
                         BlockClosure >>
                              on: exception
                              do: handlerAction

                             ” Some magic … ”

BlockClosure >> on:do:
                             ^self value.
Workspace >> evaluate
Smalltalk >> run
Exceptions
                         BlockClosure >> value

                              < Primitive >




BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                            TranscriptStream >>
                                show: anObject

                            self
                                   nextPutAll:
TranscriptStream >> show:              anObject asString;
BlockClosure >> value                  endEntry.
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                            String >> asString

                                 ^self.

String >> asString
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                            TranscriptStream >>
                                show: anObject

                            self
                                   nextPutAll:
TranscriptStream >> show:             anObject asString;
BlockClosure >> value                 endEntry.
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                                 TranscriptStream >>
                                     nextPutAll: aString

                                 ” … some code here … ”
TranscriptStream >>nextPutAll:
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                            TranscriptStream >>
                                show: anObject

                            self
                                   nextPutAll:
TranscriptStream >> show:              anObject asString;
BlockClosure >> value                  endEntry.
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                               TranscriptStream >>
                                   endEntry

                               ” … some code here … ”
TranscriptStream >> endEntry
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                            TranscriptStream >>
                                show: anObject

                            self
                                   nextPutAll:
TranscriptStream >> show:              anObject asString;
BlockClosure >> value                  endEntry.
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                         BlockClosure >> value

                              < Primitive >




BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                         BlockClosure >>
                              on: exception
                              do: handlerAction

                             ” Some magic … ”

BlockClosure >> on:do:
                             ^self value.
Workspace >> evaluate
Smalltalk >> run
Exceptions
                        Transcript show:
                             'Hello, Edinburgh!'.




Workspace >> evaluate
Smalltalk >> run
Exceptions
                                 TranscriptStream >>
                                     nextPutAll: aString

                                 ” Transcript Window cannot
TranscriptStream >>nextPutAll:   hold more text! ”
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                                 TranscriptStream >>
                                     nextPutAll: aString

                                 ” Transcript Window cannot
TranscriptStream >>nextPutAll:   hold more text! ”
TranscriptStream >> show:
BlockClosure >> value



                                   FAIL !
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                                 .Net Exceptions
                                 unwind the stack
TranscriptStream >>nextPutAll:   when thrown!
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                                 Smalltalk expects
                                 resumable
TranscriptStream >>nextPutAll:   exceptions!
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:           Stack is gone!
Workspace >> evaluate
Smalltalk >> run
Exceptions
                                 Must keep stack!
Extra code here …
BlockClosure >> value
TranscriptStream >>nextPutAll:   Code executes as
TranscriptStream >> show:
BlockClosure >> value
                                 usually.
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                                 Unwinding is
                                 executes as
TranscriptStream >>nextPutAll:
                                 usually.
TranscriptStream >> show:
BlockClosure >> value
BlockClosure >> on:do:
Workspace >> evaluate
Smalltalk >> run
Exceptions
                         List >> getItemText:
                               aString
List >> getItemText:
List.AddItem()                ^self itemTexts
List.AddItems()                     at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:

Workspace >> evaluate
Smalltalk >> run
Exceptions
                         List >> getItemText:
                               aString
List >> getItemText:
List.AddItem()                ^self itemTexts
List.AddItems()                     at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
                          KEY IS MISSING
Workspace >> evaluate
Smalltalk >> run
Exceptions
                         List >> getItemText:
                               aString
List >> getItemText:
List.AddItem()                ^self itemTexts
List.AddItems()                     at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
                          KEY IS MISSING
Workspace >> evaluate
Smalltalk >> run
Exceptions
                         List >> getItemText:
                               aString
List >> getItemText:
List.AddItem()                ^self itemTexts
List.AddItems()                     at: aString.
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:
                          KEY IS MISSING
Workspace >> evaluate
Smalltalk >> run
Exceptions
List >> getItemText:
                         Exceptions must
List.AddItem()           integrate with the
try { … } catch { … }
                         rest of the .Net!
List.AddItems()
List >> showItems:
BlockClosure >> value
BlockClosure >> on:do:

Workspace >> evaluate
Smalltalk >> run
Exceptions
Non-Resumable exceptions can be
mapped to native .Net exceptions
Exceptions
Non-Resumable exceptions can be
mapped to native .Net exceptions

Resumable exceptions cannot be
mapped to native .Net exceptions
and will need a IronSmalltalk
special implementation.

IronSmalltalk

  • 1.
    IronSmalltalk August24th 2011 Todor Todorov
  • 2.
    IronSmalltalk Smalltalkfor the Microsoft .Net DLR
  • 3.
    Agenda • History • Motivation and Background • Microsoft .Net DLR • Message Sends and CallSites • CallSite Binders • Expression Trees • Code Pipeline • Polymorphic Inline Caching • Conclusion • Extras / Bonus 24 August 2011 Todor Todorov 3 / 111
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
    Goal • X3J20 CompliantSmalltalk • First Class Member of the DLR Family • Easy interop. with .Net • Decent Performance
  • 19.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
    Message Send Transcript show: 'Hello, Edinburgh!'.
  • 28.
    Message Send Transcript show:'Hello, Edinburgh!'. TranscriptStream >> show: anObject self nextPutAll: anObject asString; endEntry.
  • 29.
    Method Lookup Transcript show:'Hello, Edinburgh!'. TranscriptStream >> show: anObject self nextPutAll: anObject asString; endEntry.
  • 30.
    Call Site Transcript show:'Hello, Edinburgh!'. call1 := Message receiver: Transcript selector: #show: arguments: #('Hello, Edinb… '). call1 evaluate.
  • 31.
    Call Site Transcript show:'Hello, Edinburgh!'. call1 := CallSite receiver: Transcript selector: #show: arguments: #('Hello, Edinb… '). call1 evaluate.
  • 32.
    Call Site Transcript show:'Hello, Edinburgh!'. call1 := CallSite selector: #show:. call1 evaluateWithReceiver: Transcript andArgs: #('Hello, Edinburgh').
  • 33.
    Call Site Binders Transcriptshow: 'Hello, Edinburgh!'. call1 := CallSite onBinder: (Binder selector: #show:). call1 evaluateWithReceiver: Transcript andArgs: #('Hello, Edinburgh').
  • 34.
    Call Site Binders Binder>> bindFor: aReceiver arguments: anArray ^BindingRule for: (aReceiver compiledMethodAt: #show).
  • 35.
  • 36.
    Call Site Binders Binder>> bindFor: aReceiver arguments: anArray ^BindingRule for: (aReceiver compiledMethodAt: #show).
  • 37.
    Call Site Binders Binder>> bindFor: aReceiver arguments: anArray ^aReceiver bindEvaluateFor: self arguments: anArray.
  • 38.
    Call Site Binders Object>> bindEvaluateFor: aBinder arguments: anArray ^BindingRule for: (self compiledMethodAt: aBinder selector). ” or return whatever it wants! ”
  • 39.
    Call Site Binders … receiver can’t help us, then … fallbackBindInvokeFor: aReceiver arguments: anArray ^BindingRule for: … some compiled method …
  • 40.
  • 41.
  • 42.
    Expression Trees Abstract SemanticTree Abstract Syntax Tree
  • 43.
    Expression Trees Abstract SemanticTree Abstract Syntax Tree Expression trees model code
  • 44.
    Expression Trees Abstract SemanticTree Abstract Syntax Tree Expression trees model code Expressions are used to represent the implementation of certain code or logic
  • 45.
    Expression Trees signString ^self < 0 ifTrue: [ 'Negative' ] ifFalse: [ 'Positive' ].
  • 46.
    Expression Trees signString ^Expression condition: (Expression lowerThan: self value: 0) true: 'Negative' false: 'Positive'.
  • 47.
    Expression Trees signString selfArg :=Expression parameter: 'self'. ^Expression condition: (Expression lowerThan: selfArg value: (Expression constant: 0)) true: (Expression constant: 'Negative') false: (Expression constant: 'Positive').
  • 48.
  • 49.
    Expression Trees self nextPutAll: anObject. selfArg := Expression parameter: 'self'. arg1 := Expression parameter: 'anObject'. ^Expression dynamic: (Binder selector: #nextPutAll:) receiver: selfArg arguments: (Array with: arg1).
  • 50.
    Expression Trees Binder >>bindFor: aReceiver arguments: anArray ^BindingRule for: (aReceiver compiledMethodAt: #nextPutAll).
  • 51.
    Expression Trees Binder >>bindFor: aReceiver arguments: anArray ^BindingRule expression: (Expression dynamic: (Binder selector: #nextPutAll:) receiver: aReceiver expression arguments: (Array with: anArray first expression).
  • 52.
  • 53.
  • 54.
    Code Pipeline Smalltalk Sources Smalltalk AST Smalltalk Parser
  • 55.
    Code Pipeline Smalltalk Sources Smalltalk Expression AST Tree Smalltalk JIT- Smalltalk Parser Compiler
  • 56.
    Code Pipeline Smalltalk Sources Smalltalk Expression MSIL AST Tree (Bytecode) Smalltalk JIT- DLR / Linq Smalltalk Parser Compiler Compiler
  • 57.
    Code Pipeline Smalltalk Sources Smalltalk Expression MSIL Machine Code AST Tree (Bytecode) Smalltalk JIT- DLR / Linq .NET CLR Smalltalk Parser Compiler Compiler (JIT Compiler)
  • 58.
  • 59.
    Caching Transcript show: 'Hello,Edinburgh!'. call1 := CallSite onBinder: (Binder selector: #show:). call1 evaluateWithReceiver: Transcript andArgs: #('Hello, Edinburgh').
  • 60.
    Caching Binder >> bindFor:aReceiver arguments: anArray method := aReceiver value compiledMethodAt: #show:. ” … magic … to generate expression from method … ” ^BindingRule expression: (Expression dynamic: (Binder selector: #nextPutAll:) receiver: aReceiver expression arguments: (Array with: anArray first expression).
  • 61.
    Caching Transcript show: 'Hello,Edinburgh!'. call1 := CallSite onBinder: (Binder selector: #show:). call1 evaluateWithReceiver: Transcript andArgs: #('Hello, Edinburgh').
  • 62.
    Caching Binder >> bindFor:aReceiver arguments: anArray method := aReceiver value compiledMethodAt: #show:. ” … magic … to generate expression from method … ” ^BindingRule expression: ” … expression … ” restriction: [ :obj | obj class = TranscriptStream ].
  • 63.
    Caching Transcript show: 'Hello,Edinburgh!'. call1 := CallSite onBinder: (Binder selector: #show:). call1 evaluateWithReceiver: Transcript andArgs: #('Hello, Edinburgh').
  • 64.
    Restrictions • Restrictions canbe more complex • For example, instance specific or object version specific • Restrictions determine the polymorphism of objects • Restrictions are the key to polymorphic inline caching!
  • 65.
    The Cache • 3 Levels of Caching: • Level 0 : Rule for last call • Level 1 : Last 10 rules • Level 2 : 100 rules, shares across similar call sites
  • 66.
  • 68.
    Common Vocabulary • NoneDefined • De-Facto, the .Net class library • We aim at reusing the common classes – Example: System.Char => Character • Not everything maps easily, but most do – Example: System.String ~= String
  • 69.
  • 70.
  • 71.
    Components Hosting Interchange Installer IC Encoder AST JIT Compiler DefinitionInstaller Runtime Compiler Core IC JitCompiler Common
  • 72.
    Hosting Windows Process .Net AppDomain .Net AppDomain DLR Script Scope Smalltalk Runtime Smalltalk (Runtime) Smalltalk Runtime Ruby / Python Smalltalk Runtime DLR Script Scope
  • 73.
  • 74.
    Object Space No Object Space Reflection No #allInstances No #allReferences No #become: But #behaveLike: is possible! Debugger inspection is possible.
  • 75.
  • 76.
    Good News Unicode Multi Threaded LargeClass Library Web-Hostable MIT License
  • 77.
    Near Future Generics Class LibraryImporter (or auto-integration) Finish Version 1.0 Write Tests (…)
  • 78.
    Future GUI Integration (WinForms+ WPF) SubSystems (Interactive) Debugger Visual Studio Integration Mixins SubSystems / Namespaces Instance Specific Behavior
  • 79.
  • 80.
    Callbacks List showItems: #( 'TT' 'ST' ). Workspace >> evaluate Smalltalk >> run
  • 81.
    Callbacks List >> showItems: anArray “ AddItems(anArray, self) ” <Windows API> List >> showItems: Workspace >> evaluate Smalltalk >> run
  • 82.
    Callbacks List.AddItems(string[] keys, dynamic stList) { for(i=0; i<…;i++) this.AddItem( keys[i], List.AddItems() stList); List >> showItems: } Workspace >> evaluate Smalltalk >> run
  • 83.
    Callbacks List.AddItem(string[] keys, dynamic stList) { string text = stList. .GetItemText(key); List.AddItem() List.AddItems() ” …somehow add it… ” List >> showItems: } Workspace >> evaluate Smalltalk >> run
  • 84.
    Callbacks List >> getItemText: aString ^self itemTexts List >> getItemText: at: aString. List.AddItem() List.AddItems() List >> showItems: Workspace >> evaluate Smalltalk >> run
  • 85.
    Callbacks .Net 4.0 has the dynamic keyword used for invoking method on dynamic objects. List >> getItemText: IronSmalltalk objects can List.AddItem() transparently be used by any DLR aware language. List.AddItems() List >> showItems: Workspace >> evaluate Smalltalk >> run
  • 86.
    Callbacks Native Name: GetItemText List >> getItemText: aString List >> getItemText: List.AddItem() List.AddItems() The native name is the List >> showItems: method name (selector) that Workspace >> evaluate is exposed to the other DLR languages. Smalltalk >> run
  • 87.
    Exceptions [ Transcript show: 'Hello, Edinburgh!' ] on: Error do: [ … ]. Workspace >> evaluate Smalltalk >> run
  • 88.
    Exceptions BlockClosure >> on: exception do: handlerAction ” Some magic … ” BlockClosure >> on:do: ^self value. Workspace >> evaluate Smalltalk >> run
  • 89.
    Exceptions BlockClosure >> value < Primitive > BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 90.
    Exceptions TranscriptStream >> show: anObject self nextPutAll: TranscriptStream >> show: anObject asString; BlockClosure >> value endEntry. BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 91.
    Exceptions String >> asString ^self. String >> asString TranscriptStream >> show: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 92.
    Exceptions TranscriptStream >> show: anObject self nextPutAll: TranscriptStream >> show: anObject asString; BlockClosure >> value endEntry. BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 93.
    Exceptions TranscriptStream >> nextPutAll: aString ” … some code here … ” TranscriptStream >>nextPutAll: TranscriptStream >> show: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 94.
    Exceptions TranscriptStream >> show: anObject self nextPutAll: TranscriptStream >> show: anObject asString; BlockClosure >> value endEntry. BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 95.
    Exceptions TranscriptStream >> endEntry ” … some code here … ” TranscriptStream >> endEntry TranscriptStream >> show: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 96.
    Exceptions TranscriptStream >> show: anObject self nextPutAll: TranscriptStream >> show: anObject asString; BlockClosure >> value endEntry. BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 97.
    Exceptions BlockClosure >> value < Primitive > BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 98.
    Exceptions BlockClosure >> on: exception do: handlerAction ” Some magic … ” BlockClosure >> on:do: ^self value. Workspace >> evaluate Smalltalk >> run
  • 99.
    Exceptions Transcript show: 'Hello, Edinburgh!'. Workspace >> evaluate Smalltalk >> run
  • 100.
    Exceptions TranscriptStream >> nextPutAll: aString ” Transcript Window cannot TranscriptStream >>nextPutAll: hold more text! ” TranscriptStream >> show: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 101.
    Exceptions TranscriptStream >> nextPutAll: aString ” Transcript Window cannot TranscriptStream >>nextPutAll: hold more text! ” TranscriptStream >> show: BlockClosure >> value FAIL ! BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 102.
    Exceptions .Net Exceptions unwind the stack TranscriptStream >>nextPutAll: when thrown! TranscriptStream >> show: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 103.
    Exceptions Smalltalk expects resumable TranscriptStream >>nextPutAll: exceptions! TranscriptStream >> show: BlockClosure >> value BlockClosure >> on:do: Stack is gone! Workspace >> evaluate Smalltalk >> run
  • 104.
    Exceptions Must keep stack! Extra code here … BlockClosure >> value TranscriptStream >>nextPutAll: Code executes as TranscriptStream >> show: BlockClosure >> value usually. BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 105.
    Exceptions Unwinding is executes as TranscriptStream >>nextPutAll: usually. TranscriptStream >> show: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 106.
    Exceptions List >> getItemText: aString List >> getItemText: List.AddItem() ^self itemTexts List.AddItems() at: aString. List >> showItems: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 107.
    Exceptions List >> getItemText: aString List >> getItemText: List.AddItem() ^self itemTexts List.AddItems() at: aString. List >> showItems: BlockClosure >> value BlockClosure >> on:do: KEY IS MISSING Workspace >> evaluate Smalltalk >> run
  • 108.
    Exceptions List >> getItemText: aString List >> getItemText: List.AddItem() ^self itemTexts List.AddItems() at: aString. List >> showItems: BlockClosure >> value BlockClosure >> on:do: KEY IS MISSING Workspace >> evaluate Smalltalk >> run
  • 109.
    Exceptions List >> getItemText: aString List >> getItemText: List.AddItem() ^self itemTexts List.AddItems() at: aString. List >> showItems: BlockClosure >> value BlockClosure >> on:do: KEY IS MISSING Workspace >> evaluate Smalltalk >> run
  • 110.
    Exceptions List >> getItemText: Exceptions must List.AddItem() integrate with the try { … } catch { … } rest of the .Net! List.AddItems() List >> showItems: BlockClosure >> value BlockClosure >> on:do: Workspace >> evaluate Smalltalk >> run
  • 111.
    Exceptions Non-Resumable exceptions canbe mapped to native .Net exceptions
  • 112.
    Exceptions Non-Resumable exceptions canbe mapped to native .Net exceptions Resumable exceptions cannot be mapped to native .Net exceptions and will need a IronSmalltalk special implementation.