스몰 토크에서 더 나은 반향을 이해하려고합니다. 최신 버전의 Squeak (v4.3)을 사용하고 있습니다. 내 수업 중 하나의 인스턴스로 전송 된 모든 메시지를 가로 채고 싶습니다. 나는 ProtoObject>>withArgs:executeMethod
메서드를 오버라이드 할 수 있다고 가정했으나 Stéphane Ducasse는 성능상의 이유로이 방법을 사용하지 않는다고 설명했습니다 (이것은 내 자신의 답변 요약입니다). 어떤 방법을 무시해야합니까/어떻게 보낸 메시지를 가로 챌 수 있습니까? 코드 수율이 전체 조각을 실행스퀵의 차단 메시지
Object subclass: #C
instanceVariableNames: 'i'
classVariableNames: ''
poolDictionaries: ''
category: 'CSE3009'.
C class compile: 'newWithi: anInt
^(self new) i: anInt ; yourself.'.
C compile: 'withArgs: someArgs executeMethod: aMethod
Transcript show: ''Caught: ''.
^super withArgs: someArgs executeMethod aMethod.'.
C compile: 'foo: aText
Transcript show: aText.
Transcript show: i.
Transcript cr.'.
C compile: 'i: anInt
i := anInt.'.
o := C newWithi: 42.
o foo: 'This is foo: '.
: 여기
는 내 시도의 코드This is foo: 42
나는이 없다 싶을 때 :
는Caught: This is foo: 42
최근 출시 된 Squeak 버전은 4.4입니다. –