Topics

Proposal to change the meaning of '<<<'

Richard Russell
 

Currently the '<<<' operator (in BB4W and BBCSDL) is an alias of '<<', they do exactly the same thing.  I'm wondering whether there would be some value in redefining '<<<' so that it acts as '<<' would in *hex 64 mode, but always (i.e. irrespective of the mode).  This would make it possible to shift a 64-bit integer left without the inconvenience (and potential risk) of changing the mode, which could be useful in a library for example.

This would of course be an incompatible change.  If somebody has used <<< in an existing program (probably by mistake) it could stop working.  But since the current help file says nothing about <<< (and it's a syntax error in Acorn's BASICs) such a failure could be argued to be the fault of the programmer for using an undocumented feature.

Do you think this would be a desirable change or not?

Richard.

 

Almost certain I’ve never used that (except perhaps in a string). It’s not present as a token in a .bbc file, I presume, so searching program files for its presence should be straightforward. I vote yes.

dai_m_leeds
 

Hi Richard,

I can see how that could be useful, and there's no real excuse that I can see for having it in existing code.

Best wishes,

D

Howard
 

Pretty sure I have never used this as I was never aware it was not a syntax error, so this sounds a good propsal to e.

Howard

Ric
 

Pretty sure I've never used it by mistake, or deliberately, seems to be sensible except that it is 3 characters long. Maybe by the time we get to 512 bits(hyperthetically) we could have <<<<<<😜

Ric

Sent from my HTC

----- Reply message -----
From: john_fowler_son@...
To: <bb4w@groups.io>
Subject: [bb4w] Proposal to change the meaning of '<<<'
Date: Fri, Jan 5, 2018 09:46

Pretty sure I have never used this as I was never aware it was not a syntax error, so this sounds a good propsal to e.

Howard

Richard Russell
 

On Sat, Jan 6, 2018 at 02:19 am, Ric wrote:
seems to be sensible except that it is 3 characters long.
But so is '>>>' which has been in BBC BASIC for at least 30 years, so I don't see how that can be an objection.  Indeed the only reason that '<<<' is accepted by BB4W and BBCSDL is because the code which handles '>>>' also recognises '<<<' as a side-effect, and with no extra effort.

Aliasing '<<<'  to '<<', as I do currently, seems natural to me because exactly the same thing happens in x86 assembly language.  The shift mnemonics SAR (signed shift right, >> in BBC BASIC) and SHR (unsigned shift right, >>> in BBC BASIC) are distinct and of course generate different opcodes.  But SAL and SHL (which you can think of as << and <<< in BBC BASIC) generate the same instruction:

065C1744 C1 F8 05  sar eax,5
065C1747 C1 E8 05  shr eax,5
065C174A C1 E0 05  sal eax,5
065C174D C1 E0 05  shl eax,5

Maybe by the time we get to 512 bits (hyperthetically) we could have <<<<<<
I know there was a smiley, but that's a false analogy.  >> and >>> are distinct only to allow you specify signed and unsigned shift-right operations; the same pair of operators suits for any number of bits.

Richard.

J.G.Harston
 

I've just done a text search and have found no instances of '<<<' outside a couple of strings.

--
J.G.Harston - jgh@... - mdfs.net/jgh