[squeak-dev] Integer>>#|

Marcel Taeumel marcel.taeumel at hpi.de
Mon May 25 07:07:01 UTC 2020


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 <btc at openinworld.com>:


On Sun, 24 May 2020 at 04:31, Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com [mailto:nicolas.cellier.aka.nice at gmail.com]> 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 <edgardec2005 at gmail.com [mailto:edgardec2005 at gmail.com]> a écrit :

Of course you right 
But Pharo have this


Sent from my iPhone

On 23 May 2020, at 12:37, Marcel Taeumel <marcel.taeumel at hpi.de [mailto:marcel.taeumel at hpi.de]> 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 <kksubbu.ml at gmail.com [mailto:kksubbu.ml at gmail.com]>:
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




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200525/0c358c53/attachment.html>


More information about the Squeak-dev mailing list