Integer>>#|

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

Integer>>#|

Edgar De Cleene
Seems
Integer>>#|

Is not in Squeak 6.0 .
Any reason ?

Edgar

Reply | Threaded
Open this post in threaded view
|

Re: Integer>>#|

K K Subbu
On 23/05/20 3:18 pm, Edgar De Cleene wrote:
> Seems
> Integer>>#|
>
> Is not in Squeak 6.0 .
> Any reason ?
AFAIK, #| has always been boolean or operator in Smalltalk. The bitwise
or is #bitOr: as in:

  2r1011 bitOr: 2r101 "15"

HTH .. Subbu

Reply | Threaded
Open this post in threaded view
|

Re: Integer>>#|

marcel.taeumel
Yes, the bit-wise operators from C translate to #bit*: messages in Smalltalk.

However, ages ago, someone started to support #>> and #<< on Integer for bit shifting. So, it is somewhat inconsistent.

Even though there are & and | in Boolean, most of the time, the code reads better with #and: or #or:. It can be challenging already to teach students the difference between "expOne or: [expTwo]" and "expOne or: (expTwo)". Adding & and | to the mix is not helpful. :-D

Next step would be to support #ifTrue:ifFalse: on Integer? Please, don't. :-)

Best,
Marcel

Am 23.05.2020 14:12:47 schrieb K K Subbu <[hidden email]>:

On 23/05/20 3:18 pm, Edgar De Cleene wrote:
> Seems
> Integer>>#|
>
> Is not in Squeak 6.0 .
> Any reason ?
AFAIK, #| has always been boolean or operator in Smalltalk. The bitwise
or is #bitOr: as in:

2r1011 bitOr: 2r101 "15"

HTH .. Subbu



Reply | Threaded
Open this post in threaded view
|

Re: Integer>>#|

Edgar De Cleene
Of course you right 
But Pharo have this

Sent from my iPhone

On 23 May 2020, at 12:37, Marcel Taeumel <[hidden email]> wrote:


Yes, the bit-wise operators from C translate to #bit*: messages in Smalltalk.

However, ages ago, someone started to support #>> and #<< on Integer for bit shifting. So, it is somewhat inconsistent.

Even though there are & and | in Boolean, most of the time, the code reads better with #and: or #or:. It can be challenging already to teach students the difference between "expOne or: [expTwo]" and "expOne or: (expTwo)". Adding & and | to the mix is not helpful. :-D

Next step would be to support #ifTrue:ifFalse: on Integer? Please, don't. :-)

Best,
Marcel

Am 23.05.2020 14:12:47 schrieb K K Subbu <[hidden email]>:

On 23/05/20 3:18 pm, Edgar De Cleene wrote:
> Seems
> Integer>>#|
>
> Is not in Squeak 6.0 .
> Any reason ?
AFAIK, #| has always been boolean or operator in Smalltalk. The bitwise
or is #bitOr: as in:

2r1011 bitOr: 2r101 "15"

HTH .. Subbu




Reply | Threaded
Open this post in threaded view
|

Re: Integer>>#|

Nicolas Cellier
Hi Edgar, Hi Marcel,

Pharo team probably wanted to lower the gap with some mainstream languages and provide same kind of "operators"...
IMO, we don't need two ways to do the same thing, and we should better let that out of Squeak.
I suggest using an optional package if compatibility matters.

However, note that for VMMaker << and >> are directed shifts and it makes a big difference.
The code generated for bitShift: has to check the sign of the shift and that ain't good.

Le sam. 23 mai 2020 à 21:50, Edgar De Cleene <[hidden email]> a écrit :
Of course you right 
But Pharo have this

Sent from my iPhone

On 23 May 2020, at 12:37, Marcel Taeumel <[hidden email]> wrote:


Yes, the bit-wise operators from C translate to #bit*: messages in Smalltalk.

However, ages ago, someone started to support #>> and #<< on Integer for bit shifting. So, it is somewhat inconsistent.

Even though there are & and | in Boolean, most of the time, the code reads better with #and: or #or:. It can be challenging already to teach students the difference between "expOne or: [expTwo]" and "expOne or: (expTwo)". Adding & and | to the mix is not helpful. :-D

Next step would be to support #ifTrue:ifFalse: on Integer? Please, don't. :-)

Best,
Marcel

Am 23.05.2020 14:12:47 schrieb K K Subbu <[hidden email]>:

On 23/05/20 3:18 pm, Edgar De Cleene wrote:
> Seems
> Integer>>#|
>
> Is not in Squeak 6.0 .
> Any reason ?
AFAIK, #| has always been boolean or operator in Smalltalk. The bitwise
or is #bitOr: as in:

2r1011 bitOr: 2r101 "15"

HTH .. Subbu





Reply | Threaded
Open this post in threaded view
|

Re: Integer>>#|

Ben Coman


On Sun, 24 May 2020 at 04:31, Nicolas Cellier <[hidden email]> wrote:
Hi Edgar, Hi Marcel,

Pharo team probably wanted to lower the gap with some mainstream languages and provide same kind of "operators"...
IMO, we don't need two ways to do the same thing, and we should better let that out of Squeak.
I suggest using an optional package if compatibility matters.

However, note that for VMMaker << and >> are directed shifts and it makes a big difference.
The code generated for bitShift: has to check the sign of the shift and that ain't good.

Apologies to divert to a Pharo query but it should be quick (even if I'm looking at the code I might not know...)
Is Pharo's #<< and #>>  equivalent to  VMMaker #<< and #>> ?
 
cheers -ben


Le sam. 23 mai 2020 à 21:50, Edgar De Cleene <[hidden email]> a écrit :
Of course you right 
But Pharo have this

Sent from my iPhone

On 23 May 2020, at 12:37, Marcel Taeumel <[hidden email]> wrote:


Yes, the bit-wise operators from C translate to #bit*: messages in Smalltalk.

However, ages ago, someone started to support #>> and #<< on Integer for bit shifting. So, it is somewhat inconsistent.

Even though there are & and | in Boolean, most of the time, the code reads better with #and: or #or:. It can be challenging already to teach students the difference between "expOne or: [expTwo]" and "expOne or: (expTwo)". Adding & and | to the mix is not helpful. :-D

Next step would be to support #ifTrue:ifFalse: on Integer? Please, don't. :-)

Best,
Marcel

Am 23.05.2020 14:12:47 schrieb K K Subbu <[hidden email]>:

On 23/05/20 3:18 pm, Edgar De Cleene wrote:
> Seems
> Integer>>#|
>
> Is not in Squeak 6.0 .
> Any reason ?
AFAIK, #| has always been boolean or operator in Smalltalk. The bitwise
or is #bitOr: as in:

2r1011 bitOr: 2r101 "15"

HTH .. Subbu






Reply | Threaded
Open this post in threaded view
|

Re: Integer>>#|

marcel.taeumel
Hi Ben.

Is Pharo's #<< and #>>  equivalent to  VMMaker #<< and #>> ?

Hmm... For a comparison, I would first take a look at the source code and generated bytecodes, respectively. :-)

Best,
Marcel

Am 24.05.2020 05:08:25 schrieb Ben Coman <[hidden email]>:



On Sun, 24 May 2020 at 04:31, Nicolas Cellier <[hidden email]> wrote:
Hi Edgar, Hi Marcel,

Pharo team probably wanted to lower the gap with some mainstream languages and provide same kind of "operators"...
IMO, we don't need two ways to do the same thing, and we should better let that out of Squeak.
I suggest using an optional package if compatibility matters.

However, note that for VMMaker << and >> are directed shifts and it makes a big difference.
The code generated for bitShift: has to check the sign of the shift and that ain't good.

Apologies to divert to a Pharo query but it should be quick (even if I'm looking at the code I might not know...)
Is Pharo's #<< and #>>  equivalent to  VMMaker #<< and #>> ?
 
cheers -ben


Le sam. 23 mai 2020 à 21:50, Edgar De Cleene <[hidden email]> a écrit :
Of course you right 
But Pharo have this

Sent from my iPhone

On 23 May 2020, at 12:37, Marcel Taeumel <[hidden email]> wrote:


Yes, the bit-wise operators from C translate to #bit*: messages in Smalltalk.

However, ages ago, someone started to support #>> and #<< on Integer for bit shifting. So, it is somewhat inconsistent.

Even though there are & and | in Boolean, most of the time, the code reads better with #and: or #or:. It can be challenging already to teach students the difference between "expOne or: [expTwo]" and "expOne or: (expTwo)". Adding & and | to the mix is not helpful. :-D

Next step would be to support #ifTrue:ifFalse: on Integer? Please, don't. :-)

Best,
Marcel

Am 23.05.2020 14:12:47 schrieb K K Subbu <[hidden email]>:

On 23/05/20 3:18 pm, Edgar De Cleene wrote:
> Seems
> Integer>>#|
>
> Is not in Squeak 6.0 .
> Any reason ?
AFAIK, #| has always been boolean or operator in Smalltalk. The bitwise
or is #bitOr: as in:

2r1011 bitOr: 2r101 "15"

HTH .. Subbu