Yes man.
Stef
> You're right. It looks like I need to sleep more :-D
>
> Noury
[bouraq...@gmail.com]
Sent: Tuesday, January 18, 2011 6:29 AM
To: Pharo-project@lists.gforge.inria.fr
Subject: [Pharo-project] Surprising binary messages!
5 is the surprising answer of the expression:
6 + 4 / 2
It should be 8
But, I got 5 in both 1.1 and 1.2.
Noury
You're right. It looks like I need to sleep more :-D
Noury
On 18 janv. 2011, at 12:38, Stéphane Ducasse wrote:
> but this is normal. It was always like that. No operator precedence just
> messages
>
> binary are evaluated from right to left
> 6 + 4
> 10 / 2
>
On Tue, Jan 18, 2011 at 12:40 PM, Stéphane Ducasse
wrote:
>>
>> I'm just starting to learn smalltalk (thanks to PbE), but I'm pretty
>> sure I know why this happens :-)
>
> Excellent! I like that our energy helps people.
>
It really does!
Thanks to all the Pharo/Squeak community for the great eff
>
> I'm just starting to learn smalltalk (thanks to PbE), but I'm pretty
> sure I know why this happens :-)
Excellent! I like that our energy helps people.
> Smalltalk has no knowledge of mathematics order, just operation order.
> In this case + and / are both binary operators so the operations
On 18 January 2011 12:29, Noury Bouraqadi wrote:
> 5 is the surprising answer of the expression:
> 6 + 4 / 2
>
> It should be 8
> But, I got 5 in both 1.1 and 1.2.
>
this is first thing all smalltalkers learn: smalltalk syntax does not
using math operators precedence rules.
because #+ and #/ is j
but this is normal. It was always like that. No operator precedence just
messages
binary are evaluated from right to left
6 + 4
10 / 2
5
> 5 is the surprising answer of the expression:
> 6 + 4 / 2
>
> It should be 8
> But, I got 5 in b
On Tue, Jan 18, 2011 at 12:29 PM, Noury Bouraqadi wrote:
> 5 is the surprising answer of the expression:
> 6 + 4 / 2
>
> It should be 8
> But, I got 5 in both 1.1 and 1.2.
>
> Noury
>
Hi,
I'm just starting to learn smalltalk (thanks to PbE), but I'm pretty
sure I know why this happens :-)
Smallt
Why should it be 8?
#+ and #/ have the same priority and they will be evaluated from left to right.
Cheers,
Doru
On 18 Jan 2011, at 12:29, Noury Bouraqadi wrote:
> 5 is the surprising answer of the expression:
> 6 + 4 / 2
>
> It should be 8
> But, I got 5 in both 1.1 and 1.2.
>
> Noury
>
There is no such priority in smalltalk. + / - * are just normal binary
messages - they take precedence over keyword messages and are second
in line after unary ones.
And everything is executed left to right so 5 is an expected answer here.
Regards,
Stanislav Paskalev
On Tue, Jan 18, 2011 at 1:
On Jan 18, 2011, at 12:30 PM, Noury Bouraqadi wrote:
> 5 is the surprising answer of the expression:
> 6 + 4 / 2
>
> It should be 8
> But, I got 5 in both 1.1 and 1.2.
Why? 6 + 4 is 10 and devided by 2 is 5.
(there is no operator precedence)
Marcus
--
Marcus Denker -- http://www.ma
5 is the surprising answer of the expression:
6 + 4 / 2
It should be 8
But, I got 5 in both 1.1 and 1.2.
Noury
12 matches
Mail list logo