The Inbox: Kernel-ul.1059.mcz

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

The Inbox: Kernel-ul.1059.mcz

commits-2
Levente Uzonyi uploaded a new version of Kernel to project The Inbox:
http://source.squeak.org/inbox/Kernel-ul.1059.mcz

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

Name: Kernel-ul.1059
Author: ul
Time: 11 February 2017, 3:00:22.370854 am
UUID: b88b767b-b0d8-43ff-ba86-a19b11affe6d
Ancestors: Kernel-ul.1058

- check the type of the argument of #& and #| of booleans

=============== Diff against Kernel-ul.1058 ===============

Item was changed:
  ----- Method: False>>& (in category 'logical operations') -----
  & aBoolean
+ "Evaluating conjunction -- answer false since receiver is false, but let the VM quickly check the type of the argument first."
- "Evaluating conjunction -- answer false since receiver is false."
 
+ aBoolean ifFalse: [ ^false ].
+ ^false!
- ^self!

Item was changed:
  ----- Method: False>>| (in category 'logical operations') -----
  | aBoolean
+ "Evaluating disjunction (OR) -- could  answer aBoolean since receiver is false, but let the VM quickly check the type of the argument instead."
- "Evaluating disjunction (OR) -- answer with the argument, aBoolean."
 
+ aBoolean ifTrue: [ ^true ].
+ ^false!
- ^aBoolean!

Item was changed:
  ----- Method: True>>& (in category 'logical operations') -----
  & aBoolean
+ "Evaluating conjunction -- could answer aBoolean since receiver is true, but let the VM quickly check the type of the argument instead."
- "Evaluating conjunction -- answer aBoolean since receiver is true."
 
+ aBoolean ifFalse: [ ^false ].
+ ^true!
- ^aBoolean!

Item was changed:
  ----- Method: True>>| (in category 'logical operations') -----
  | aBoolean
+ "Evaluating disjunction (OR) -- answer true since the receiver is true, but let the VM quickly check the type of the argument first."
- "Evaluating disjunction (OR) -- answer true since the receiver is true."
 
+ aBoolean ifTrue: [ ^true ].
+ ^true!
- ^self!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-ul.1059.mcz

Tobias Pape
Hi Levente

On 11.02.2017, at 03:04, [hidden email] wrote:

> Levente Uzonyi uploaded a new version of Kernel to project The Inbox:
> http://source.squeak.org/inbox/Kernel-ul.1059.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-ul.1059
> Author: ul
> Time: 11 February 2017, 3:00:22.370854 am
> UUID: b88b767b-b0d8-43ff-ba86-a19b11affe6d
> Ancestors: Kernel-ul.1058
>
> - check the type of the argument of #& and #| of booleans

Why do we want the check?
I see no advantage…

Best regards
        -Tobias

>
> =============== Diff against Kernel-ul.1058 ===============
>
> Item was changed:
>  ----- Method: False>>& (in category 'logical operations') -----
>  & aBoolean
> + "Evaluating conjunction -- answer false since receiver is false, but let the VM quickly check the type of the argument first."
> - "Evaluating conjunction -- answer false since receiver is false."
>
> + aBoolean ifFalse: [ ^false ].
> + ^false!
> - ^self!
>
> Item was changed:
>  ----- Method: False>>| (in category 'logical operations') -----
>  | aBoolean
> + "Evaluating disjunction (OR) -- could  answer aBoolean since receiver is false, but let the VM quickly check the type of the argument instead."
> - "Evaluating disjunction (OR) -- answer with the argument, aBoolean."
>
> + aBoolean ifTrue: [ ^true ].
> + ^false!
> - ^aBoolean!
>
> Item was changed:
>  ----- Method: True>>& (in category 'logical operations') -----
>  & aBoolean
> + "Evaluating conjunction -- could answer aBoolean since receiver is true, but let the VM quickly check the type of the argument instead."
> - "Evaluating conjunction -- answer aBoolean since receiver is true."
>
> + aBoolean ifFalse: [ ^false ].
> + ^true!
> - ^aBoolean!
>
> Item was changed:
>  ----- Method: True>>| (in category 'logical operations') -----
>  | aBoolean
> + "Evaluating disjunction (OR) -- answer true since the receiver is true, but let the VM quickly check the type of the argument first."
> - "Evaluating disjunction (OR) -- answer true since the receiver is true."
>
> + aBoolean ifTrue: [ ^true ].
> + ^true!
> - ^self!
>
>


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-ul.1059.mcz

Levente Uzonyi
Hi Tobias,

On Sat, 11 Feb 2017, Tobias Pape wrote:

> Hi Levente
>
> On 11.02.2017, at 03:04, [hidden email] wrote:
>
>> Levente Uzonyi uploaded a new version of Kernel to project The Inbox:
>> http://source.squeak.org/inbox/Kernel-ul.1059.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Kernel-ul.1059
>> Author: ul
>> Time: 11 February 2017, 3:00:22.370854 am
>> UUID: b88b767b-b0d8-43ff-ba86-a19b11affe6d
>> Ancestors: Kernel-ul.1058
>>
>> - check the type of the argument of #& and #| of booleans
>
> Why do we want the check?
> I see no advantage…
Not too long ago there was this thread[1] with the following kind of
example:

a = b | c = d ifTrue: [ ... ].

The type check will quickly let you know if you forget a pair of
parentheses:

a = b | (c = d) ifTrue: [ ... ].

The runtime is about 1.5-2x compared to the original methods, but if you
use #| and #&, you probably don't care about performance anyway.

Levente

[1] http://forum.world.st/I-was-surprised-td4928576.html

>
> Best regards
> -Tobias
>
>>
>> =============== Diff against Kernel-ul.1058 ===============
>>
>> Item was changed:
>>  ----- Method: False>>& (in category 'logical operations') -----
>>  & aBoolean
>> + "Evaluating conjunction -- answer false since receiver is false, but let the VM quickly check the type of the argument first."
>> - "Evaluating conjunction -- answer false since receiver is false."
>>
>> + aBoolean ifFalse: [ ^false ].
>> + ^false!
>> - ^self!
>>
>> Item was changed:
>>  ----- Method: False>>| (in category 'logical operations') -----
>>  | aBoolean
>> + "Evaluating disjunction (OR) -- could  answer aBoolean since receiver is false, but let the VM quickly check the type of the argument instead."
>> - "Evaluating disjunction (OR) -- answer with the argument, aBoolean."
>>
>> + aBoolean ifTrue: [ ^true ].
>> + ^false!
>> - ^aBoolean!
>>
>> Item was changed:
>>  ----- Method: True>>& (in category 'logical operations') -----
>>  & aBoolean
>> + "Evaluating conjunction -- could answer aBoolean since receiver is true, but let the VM quickly check the type of the argument instead."
>> - "Evaluating conjunction -- answer aBoolean since receiver is true."
>>
>> + aBoolean ifFalse: [ ^false ].
>> + ^true!
>> - ^aBoolean!
>>
>> Item was changed:
>>  ----- Method: True>>| (in category 'logical operations') -----
>>  | aBoolean
>> + "Evaluating disjunction (OR) -- answer true since the receiver is true, but let the VM quickly check the type of the argument first."
>> - "Evaluating disjunction (OR) -- answer true since the receiver is true."
>>
>> + aBoolean ifTrue: [ ^true ].
>> + ^true!
>> - ^self!
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-ul.1059.mcz

Tobias Pape

On 11.02.2017, at 11:11, Levente Uzonyi <[hidden email]> wrote:

> Hi Tobias,
>
> On Sat, 11 Feb 2017, Tobias Pape wrote:
>
>> Hi Levente
>>
>> On 11.02.2017, at 03:04, [hidden email] wrote:
>>
>>> Levente Uzonyi uploaded a new version of Kernel to project The Inbox:
>>> http://source.squeak.org/inbox/Kernel-ul.1059.mcz
>>> ==================== Summary ====================
>>> Name: Kernel-ul.1059
>>> Author: ul
>>> Time: 11 February 2017, 3:00:22.370854 am
>>> UUID: b88b767b-b0d8-43ff-ba86-a19b11affe6d
>>> Ancestors: Kernel-ul.1058
>>> - check the type of the argument of #& and #| of booleans
>>
>> Why do we want the check?
>> I see no advantage…
>
> Not too long ago there was this thread[1] with the following kind of example:
>
> a = b | c = d ifTrue: [ ... ].
>
> The type check will quickly let you know if you forget a pair of parentheses:
>
> a = b | (c = d) ifTrue: [ ... ].
>
> The runtime is about 1.5-2x compared to the original methods, but if you use #| and #&, you probably don't care about performance anyway.
>
> Levente
>
> [1] http://forum.world.st/I-was-surprised-td4928576.html
>

Sure.
I however liked the simplicity of the old methods :/

>>
>> Best regards
>> -Tobias
>>
>>> =============== Diff against Kernel-ul.1058 ===============
>>> Item was changed:
>>> ----- Method: False>>& (in category 'logical operations') -----
>>> & aBoolean + "Evaluating conjunction -- answer false since receiver is false, but let the VM quickly check the type of the argument first."
>>> - "Evaluating conjunction -- answer false since receiver is false."
>>> + aBoolean ifFalse: [ ^false ].
>>> + ^false!
>>> - ^self!
>>> Item was changed:
>>> ----- Method: False>>| (in category 'logical operations') -----
>>> | aBoolean + "Evaluating disjunction (OR) -- could  answer aBoolean since receiver is false, but let the VM quickly check the type of the argument instead."
>>> - "Evaluating disjunction (OR) -- answer with the argument, aBoolean."
>>> + aBoolean ifTrue: [ ^true ].
>>> + ^false!
>>> - ^aBoolean!
>>> Item was changed:
>>> ----- Method: True>>& (in category 'logical operations') -----
>>> & aBoolean + "Evaluating conjunction -- could answer aBoolean since receiver is true, but let the VM quickly check the type of the argument instead."
>>> - "Evaluating conjunction -- answer aBoolean since receiver is true."
>>> + aBoolean ifFalse: [ ^false ].
>>> + ^true!
>>> - ^aBoolean!
>>> Item was changed:
>>> ----- Method: True>>| (in category 'logical operations') -----
>>> | aBoolean + "Evaluating disjunction (OR) -- answer true since the receiver is true, but let the VM quickly check the type of the argument first."
>>> - "Evaluating disjunction (OR) -- answer true since the receiver is true."
>>> + aBoolean ifTrue: [ ^true ].
>>> + ^true!
>>> - ^self!