Close

More operator symbols

yann-guidon-ygdesYann Guidon / YGDES wrote 11/24/2023 at 14:51 • 1 min read • Like

To say that I am frustrated by the vocabulary of some common languages is an understatement. JavaScript introduced the ">>>" symbol for the arithmetic (sign-preserving) shift but we're still far from satisfaction.

The Pascal family of languages don't bother with such details because operators use all-letters operators : sll, shl... But the C-like syntax is preferred today so I need to be creative.

Carry-related operations are traditionally absent, which is a shame. So let's skip directly to the rotations : there is no direct symbol for this, but I have long wanted to modify the shift symbols:

<<@  rotate left

>>@  rotate right

 Or maybe a shorter version:

<@  rotate left

@>  rotate right

which is less effort than having to analyse the syntax tree and look for a compound operation (OR of two SHIFTs with the same arguments and the shift amounts sum up to 32 or 64).

Now there is an even trickier symbol to choose : I need UMIN, UMAX, SMIN and SMAX (unsigned and signed minimum and maximum) The < and > symbols will be used but how to discern between signed and non signed operations ?

<? MIN

?> MAX

The Dollar symbol looks like a S so

<$ SMIN 

$> SMAX

could do the trick.

Any advice or prior art is welcome !

Like

Discussions