lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 12/7/2010 9:20 AM, Ralph Hempel wrote:
Vaughan McAlley wrote:
On 7 December 2010 05:16, Ralph Hempel wrote:

It seems to me that really only three operators needed, and the
implied direction of the shift value should be consistent across
all three, like this:

ashift - arithmetic shift (+right -left )
rotate - rotate (+right -left)
lshift - logical shift (+right -left)

I seem to recall that idea being proposed by the devs and it going
down very badly. Luckily with Lua it’s trivial to alias arshift as
ashift.
[snip snip]

I fully respect the language author's decision to do it whichever way
they choose. I was just pointing out the inconsistency in the shift
operators in case they had been staring at it so long that it was not
obvious to them :-)

The direction is not immediately obvious unless you use the calls regularly. So in the normal case, people will slow down with such speed bumps.

We think we saved on bytes and efficiency, but no matter how good a programmer we are, the cognitive effort in reading code containing them is increased. Of course, different people like different levels of abstraction.

Perhaps it is better to think in terms of how a beginner user would see such stuff in pbLua rather than making a case for orthogonal elegance.

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia