The Trunk: Kernel-nice.613.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-nice.613.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.613.mcz

==================== Summary ====================

Name: Kernel-nice.613
Author: nice
Time: 29 August 2011, 12:20:33.523 am
UUID: c5ac2f0a-3419-41d9-a4e5-0331ff55467d
Ancestors: Kernel-cmm.612

Don't provide separate setters for Complex #real: and #imaginary: parts.
Instead, provide a single #real:imaginary: initializer, that's faster and safer (like Magnitude, Complex numbers might be shared and it would be dangerous to modify a Complex in place).

=============== Diff against Kernel-cmm.612 ===============

Item was changed:
  ----- Method: Complex class>>real:imaginary: (in category 'instance creation') -----
  real: aNumber1 imaginary: aNumber2
+ ^self basicNew real: aNumber1 imaginary: aNumber2!
- | newComplex |
- newComplex := super new.
- newComplex
- real: aNumber1;
- imaginary: aNumber2.
- ^ newComplex!

Item was removed:
- ----- Method: Complex>>imaginary: (in category 'private') -----
- imaginary: aNumber
- imaginary := aNumber.!

Item was removed:
- ----- Method: Complex>>real: (in category 'private') -----
- real: aNumber
- real := aNumber.!

Item was added:
+ ----- Method: Complex>>real:imaginary: (in category 'private') -----
+ real: aNumber1 imaginary: aNumber2
+ "Private - initialize the real and imaginary parts of a Complex"
+ real := aNumber1.
+ imaginary := aNumber2.!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.613.mcz

Frank Shearar-3
On 28 August 2011 23:20,  <[hidden email]> wrote:

> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
> http://source.squeak.org/trunk/Kernel-nice.613.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-nice.613
> Author: nice
> Time: 29 August 2011, 12:20:33.523 am
> UUID: c5ac2f0a-3419-41d9-a4e5-0331ff55467d
> Ancestors: Kernel-cmm.612
>
> Don't provide separate setters for Complex #real: and #imaginary: parts.
> Instead, provide a single #real:imaginary: initializer, that's faster and safer (like Magnitude, Complex numbers might be shared and it would be dangerous to modify a Complex in place).
>
> =============== Diff against Kernel-cmm.612 ===============

If I read my image correctly, this change is the final bit needed to
make Complex "purely functional", in the sense that (apart from the
inescapable full-state-setter (and crazy things like #instVarAt:put:))
a Complex's state cannot change.

Nice!

frank

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.613.mcz

Nicolas Cellier
2011/8/29 Frank Shearar <[hidden email]>:

> On 28 August 2011 23:20,  <[hidden email]> wrote:
>> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
>> http://source.squeak.org/trunk/Kernel-nice.613.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Kernel-nice.613
>> Author: nice
>> Time: 29 August 2011, 12:20:33.523 am
>> UUID: c5ac2f0a-3419-41d9-a4e5-0331ff55467d
>> Ancestors: Kernel-cmm.612
>>
>> Don't provide separate setters for Complex #real: and #imaginary: parts.
>> Instead, provide a single #real:imaginary: initializer, that's faster and safer (like Magnitude, Complex numbers might be shared and it would be dangerous to modify a Complex in place).
>>
>> =============== Diff against Kernel-cmm.612 ===============
>
> If I read my image correctly, this change is the final bit needed to
> make Complex "purely functional", in the sense that (apart from the
> inescapable full-state-setter (and crazy things like #instVarAt:put:))
> a Complex's state cannot change.
>
> Nice!
>
> frank
>

Well, I only reduced the temptation, but did not eliminate it, one can
always call the initializer twice... Newspeak is better protected if I
understood.

Nicolas

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-nice.613.mcz

Frank Shearar-3
On 29 August 2011 00:04, Nicolas Cellier
<[hidden email]> wrote:

> 2011/8/29 Frank Shearar <[hidden email]>:
>> On 28 August 2011 23:20,  <[hidden email]> wrote:
>>> Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
>>> http://source.squeak.org/trunk/Kernel-nice.613.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Kernel-nice.613
>>> Author: nice
>>> Time: 29 August 2011, 12:20:33.523 am
>>> UUID: c5ac2f0a-3419-41d9-a4e5-0331ff55467d
>>> Ancestors: Kernel-cmm.612
>>>
>>> Don't provide separate setters for Complex #real: and #imaginary: parts.
>>> Instead, provide a single #real:imaginary: initializer, that's faster and safer (like Magnitude, Complex numbers might be shared and it would be dangerous to modify a Complex in place).
>>>
>>> =============== Diff against Kernel-cmm.612 ===============
>>
>> If I read my image correctly, this change is the final bit needed to
>> make Complex "purely functional", in the sense that (apart from the
>> inescapable full-state-setter (and crazy things like #instVarAt:put:))
>> a Complex's state cannot change.
>>
>> Nice!
>>
>> frank
>>
>
> Well, I only reduced the temptation, but did not eliminate it, one can
> always call the initializer twice... Newspeak is better protected if I
> understood.

Oh, yes: and even if you tried to subtly protect against this, you'd
still be doomed to fail. But I reckon the answer to that is "well, if
it hurts when you bypass the contract of the object, don't do that."

At least, in the Smalltalk we currently know and love: but there are
some interesting projects people are running - Newspeak, Spoon,
SecureSqueak, ...  - that we can potentially let mature and then
harvest :)

frank

> Nicolas
>
>