Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Pragmas: Literal Messages as Powerful Method Annotations

534 views

Published on

IWST 16

Published in: Software
  • Be the first to comment

  • Be the first to like this

Pragmas: Literal Messages as Powerful Method Annotations

  1. 1. Pragmas: Literal Messages as Powerful Method Annotations Stéphane Ducasse, Eliot Miranda and Alain Plantec Eliot Miranda/Steve Dahl/Vassili Bykov
  2. 2. Smalltalk
 has: #unary , #binary and: #(keyword messages)
 and: $A rich: ‘literal’
 syntax: 12345678 who do we appreciate size "Primitive. Answer the number of indexable variables in the receiver. This value is the same as the largest legal subscript. Essential. See Object documentation whatIsAPrimitive." <primitive: 62> self class isVariable ifFalse: [self errorNotIndexable]. ^ 0
  3. 3. Behavior methods for creating method dictionary addSelector: selector withMethod: compiledMethod "Add the message selector with the corresponding compiled method to the receiver’s method dictionary." methodDict at: selector put:
 (self validateMethod: compiledMethod forSelector: selector). self flushVMmethodCacheEntriesFor: selector BlockClosure class methods for private validateMethod: compiledMethod forSelector: selector "Intercept this so we can mark unwind method" | method | method := super validateMethod: compiledMethod
 forSelector: selector. ^((selector == #valueOnUnwindDo: or: [selector == #valueNowOrOnUnwindDo:]) ifTrue: [method asUnwindMethod] ifFalse: [method])
  4. 4. inspectUndeclared <menuItem: ‘Inspect Undeclared’
 nameKey: nil
 menu: #(#menuBar #browse #inspect)
 position: 15.1> Undeclared inspect
  5. 5. inspectUndeclared <menuItem: ‘Inspect Undeclared’
 nameKey: nil
 menu: #(#menuBar #browse #inspect)
 position: 15.1> Undeclared inspect [Smalltalk hasMetaObjects]
 on: MessageNotUnderstood
 do: [:ex| ex message]
  6. 6. inspectUndeclared <menuItem: ‘Inspect Undeclared’
 nameKey: nil
 menu: #(#menuBar #browse #inspect)
 position: 15.1> Undeclared inspect [Smalltalk hasMetaObjects]
 on: MessageNotUnderstood
 do: [:ex| ex message] Smalltalk perform: #hasMetaObjects withArguments: #()
  7. 7. inspectUndeclared <menuItem: ‘Inspect Undeclared’
 nameKey: nil
 menu: #(#menuBar #browse #inspect)
 position: 15.1> Undeclared inspect [Smalltalk hasMetaObjects]
 on: MessageNotUnderstood
 do: [:ex| ex message] Smalltalk perform: #hasMetaObjects withArguments: #() add/remove => select/collect => visit & apply => update
  8. 8. integrat|ed/ion • subset of language • senders/implementors browsing works • Convenient access (Vassili)
 Pragma allNamed: symbol from: subclass to: superclass
  9. 9. more generally useful • COM server
 api method pragma vs class side config • Preferences
  10. 10. AboutVisualWorksPage class
 pagePragma <pragmas: #class> ^#(pageOrder:) systemPragma <pragmas: #class> ^#(systemInformation:) 
 ApplicationModel class
 menuMethodPragmas <pragmas: #instance> ^Menu pragmas BlockClosure class
 exceptionPragmas <pragmas: #instance> ^#(exception:) L e g a l
 i
 t y
  11. 11. more generally useful • Trippy/GlamourousToolkit inspector pages • Examples • …?

×