• 検索結果がありません。

Recent site activity smalltalkusers.jp

N/A
N/A
Protected

Academic year: 2018

シェア "Recent site activity smalltalkusers.jp"

Copied!
23
0
0

読み込み中.... (全文を見る)

全文

(1)
(2)

動機

 Smalltalk superpowers紹 super

関わ 何 い

 実際OOPSLA 2008 Smalltalk

superpowers Travis Griggs さ

super super 話 模様

(3)

特徴

通常

super

 ソッ 探索 自分 ー ークラ 開始

super super

 ソッ 探索 自分 ー ークラ ー ー

クラ 開始

 ッセー super super super super

書 こ 可能

(4)

Travis

実装

VisualWorks

行わ

Squeak

 い 調子 乗 ソッ 探索 自分

サ クラ 開始 sub 作

使

クニック

(5)

クニック

(1)

 Object >> doesNotUnderstand: aMessage

 理解 い ッセー VM

送信さ コー ック

 aMessage 送 ッセー 入

 Ruby method_missing

 オー ーライ ッセー 自分以外

(6)

: doesNotUnderstand:

 実装

MyLogProxy >> doesNotUnderstand: aMessage Logger log: aMessage.

^ realObj perform: aMessage selector

(7)

クニック

(2)

CompiledMethod

 そ 通 コン イ さ ソッ

 各クラ 持 methoDictionary 値 格

納さ い

○ ー ッセー セ クタ ンボ

 aClass compiledMethodAt: selector 出

○ aClass >> selector

 イ コー い 回

(8)

: CompiledMethod

ソッ

起動

 通常 場合

ord := OrderedCollection with: 1 with: 2. ord add: 3.

ord := OrderedCollection with: 1 with: 2.

method := ord class compiledMethodAt: #add:. method valueWithReceiver: ord arguments: #(3).

(9)

クニック

(3)

thisContext

 実行中 コン 入 い 特殊変数

○ true, false, nil, self, super 次 第6 予約語

○ 約束事 少 いSmalltalk 希有 存在

 典型的 ッ 実装 使わ

 thisContext sender 送信者 コン 得

(10)

: thisContext

アクセ

制御

 private ソッ 実装 ※

Object >> private

self class = thisContext sender sender methodClass ifFalse: [SmallTalkAccessViolation private signal]

methodA

self private. ...

 使用例

(11)

コー

解説

(1)

 AnySend いうクラ 定義

ProtoObject subclass: #AnySend

instanceVariableNames: 'receiver searchClass' classVariableNames: ''

poolDictionaries: ''

category: 'SuperSuper'

 receiver -> ッセー 手

(12)

コー

解説

(2)

 AnySend ProtoObject(Object さ 上) 継承

 全 ッセー 答え い

doesNotUnderstand: 起動さ

 CompiledMethod 出 起動

doesNotUnderstand: aMessage

^((searchClass whichClassIncludesSelector:

aMessage selector) >> aMessage selector) valueWithReceiver: receiver

(13)

コー

解説

(3)

 Object >> super 用意

 AnySend super: supersuper: 作

 thisContext 直前 super(変数) 使 い 判断

super

| context sendCode |

context := thisContext sender.

sendCode := context method at: context pc - 2. ^(sendCode == 133)

(14)

コー

解説

(4)

 AnySend class >> self:

self: anObject

^self receiver: anObject

searchClass: anObject class

 生成用 クラ ソッ 定義

super: anObject

^(self self: anObject) super

(15)

コー

解説

(5)

super

searchClass := searchClass superclass supersuper: anObject

^(self super: anObject) super  う少 生成用 クラ ソッ

 AnySend class >> supersuper:

 AnySend >> super superclass

(16)
(17)

調子

sub

追加

(1)

 AnySend class >> sub:

sub: anObject

^(self self: anObject) sub

 AnySend >> sub

sub

searchClass := searchClass subclass

subclass

^self subclassAt: 1

(18)

調子

sub

追加

(2)

 Behavior >> subclassAt:

subclassAt: anIndex | subs |

subs := self subclasses

ifEmpty: [self error: 'No subclass']. ^subs at: anIndex

ifAbsent: [self error:

(19)

クラ

(1)

methodA

((self sub @ 2) sub @ 3) doSomething

 2番目 サ クラ 3番目 サ クラ

doSomething 起動

書 クー !!

methodB

((self sub << ClassA) sub << ClassB) doSomething

(20)

クラ

(2)

 AnySend class >> sub

@ anInteger

(searchClass inheritsFrom: receiver class)

ifFalse: [self error: '@ can be used after sub']. searchClass := searchClass superclass

subclassAt: anInteger

(21)

クラ

(3)

<< aClass

…"@ "

searchClass := searchClass superclass

subclassClassOf: aClass

 AnySend >> <<

subclassClassOf: aClass

^self subclassAt: (self subclasses indexOf: aClass)

(22)

 sub super 使 無限 ー

Top >> doSomethingLoopy self waitASecond.

self doSomething: 'Hello'.

self sub sub doSomethingLoopy.

Middle >> doSomethingLoopy self doSomething: '!!!!'.

super doSomethingLoopy.

Bottom >> doSomethingLoopy self doSomething: 'World'.

(23)

Smalltalk

ソッ

探索

仕方

簡単

 クラ 一 導入 い ソッ

追加

 新 言語 作

開発

super super

使

参照

関連したドキュメント

Doing Enumerative Combinatorics, we avoid studying any sequence WITHOUT nice formula.... We just ignore

The categories of prespectra, symmetric spectra and orthogonal spec- tra each carry a cofibrantly generated, proper, topological model structure with fibrations and weak

LOBBY LOUNGE ロビーラウンジ BEACH SIDE レストラン ビーチサイド ADAN 阿檀.

This “index jumping” phenomenon in order to stay on a “continuous eigenvalue branch” is quite general: It applies to all simple eigenvalues for all boundary conditions on the jump

Raimond, (2009), A Bakry-Emery Criterion for self-interacting diffusions., Seminar on Stochastic Analysis, Random Fields and Applications V, 19–22, Progr. Probab., 59,

Thus, starting with a bivariate function which is a tensor- product of finitely supported totally positive refinable functions, the new functions are obtained by using the

Arnold This paper deals with recent applications of fractional calculus to dynamical sys- tems in control theory, electrical circuits with fractance, generalized voltage di-

Arnold This paper deals with recent applications of fractional calculus to dynamical sys- tems in control theory, electrical circuits with fractance, generalized voltage di-