这是 Squeak 4.1 中的除法方法:
/t1
| t2 |
t1 isInteger
ifTrue: [t2 := self digitDiv: t1 abs neg: self negative ~~ t1 negative.
(t2 at: 2)
= 0
ifTrue: [^ (t2 at: 1) normalize].
^ (Fraction numerator: self denominator: t1) reduced].
^ t1 adaptToInteger: self andSend: #/
我不明白代码。你能给我一些关于如何调试代码的提示,以便我可以跟踪代码行为吗?就像打开一个工作区一样,输入 4/3,我可以检查 Fraction。对象有self、分子、分母等。如何步入4/3,看看Smalltalk是如何实现除法的?