Skip to content

Commit decb053

Browse files
authored
chore(stdlib)!: Update Operator uint operator Names (#1738)
* chore(stdlib): Update Operator Names * chore(stdlib): Update docs and tests
1 parent eadc71f commit decb053

File tree

13 files changed

+49
-49
lines changed

13 files changed

+49
-49
lines changed

compiler/test/stdlib/uint16.test.gr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ from Uint16 use {
1212
(-),
1313
(*),
1414
(/),
15-
(%),
15+
rem as (%),
1616
(&),
1717
(|),
1818
(^),
1919
(<<),
20-
(>>),
20+
(>>>),
2121
}
2222

2323
// Suppress warnings about using `fromNumber` on constants, since that's what we want to test.
@@ -70,9 +70,9 @@ assert 1uS << 1uS == 2uS
7070
assert 1uS << 16uS == 0uS
7171
assert 24uS << 1uS == 48uS
7272

73-
assert 4uS >> 1uS == 2uS
74-
assert 4uS >> 2uS == 1uS
75-
assert 4uS >> 3uS == 0uS
73+
assert 4uS >>> 1uS == 2uS
74+
assert 4uS >>> 2uS == 1uS
75+
assert 4uS >>> 3uS == 0uS
7676

7777
assert incr(0uS) == 1uS
7878
assert incr(0xffffuS) == 0uS

compiler/test/stdlib/uint32.test.gr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ from Uint32 use {
1212
(|),
1313
(^),
1414
(<<),
15-
(>>),
15+
(>>>),
1616
clz,
1717
ctz,
1818
popcnt,
@@ -55,11 +55,11 @@ assert 1ul << 3ul == 8ul
5555
assert 2ul << 63ul == 0ul
5656
assert 24ul << 1ul == 48ul
5757

58-
assert 4ul >> 1ul == 2ul
59-
assert 4ul >> 2ul == 1ul
60-
assert 4ul >> 3ul == 0ul
61-
assert 1ul >> 63ul == 0ul
62-
assert 0xfffffffful >> 63ul == 1ul
58+
assert 4ul >>> 1ul == 2ul
59+
assert 4ul >>> 2ul == 1ul
60+
assert 4ul >>> 3ul == 0ul
61+
assert 1ul >>> 63ul == 0ul
62+
assert 0xfffffffful >>> 63ul == 1ul
6363

6464
assert clz(0b11ul) == 30ul
6565
assert ctz(0b11000ul) == 3ul

compiler/test/stdlib/uint64.test.gr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ from Uint64 use {
1212
(|),
1313
(^),
1414
(<<),
15-
(>>),
15+
(>>>),
1616
clz,
1717
ctz,
1818
popcnt,
@@ -57,12 +57,12 @@ assert 1uL << 3uL == 8uL
5757
assert 2uL << 63uL == 0uL
5858
assert 24uL << 1uL == 48uL
5959

60-
assert 4uL >> 1uL == 2uL
61-
assert 4uL >> 2uL == 1uL
62-
assert 4uL >> 3uL == 0uL
63-
assert 4uL >> 4uL == 0uL
64-
assert 24uL >> 1uL == 12uL
65-
assert 0xffffffffffffffffuL >> 63uL == 1uL
60+
assert 4uL >>> 1uL == 2uL
61+
assert 4uL >>> 2uL == 1uL
62+
assert 4uL >>> 3uL == 0uL
63+
assert 4uL >>> 4uL == 0uL
64+
assert 24uL >>> 1uL == 12uL
65+
assert 0xffffffffffffffffuL >>> 63uL == 1uL
6666

6767
assert clz(0b11uL) == 62uL
6868
assert ctz(0b11000uL) == 3uL

compiler/test/stdlib/uint8.test.gr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ from Uint8 use {
1212
(-),
1313
(*),
1414
(/),
15-
(%),
15+
rem as (%),
1616
(&),
1717
(|),
1818
(^),
1919
(<<),
20-
(>>),
20+
(>>>),
2121
}
2222

2323
// Suppress warnings about using `fromNumber` on constants, since that's what we want to test.
@@ -69,9 +69,9 @@ assert 1us << 1us == 2us
6969
assert 1us << 8us == 0us
7070
assert 24us << 1us == 48us
7171

72-
assert 4us >> 1us == 2us
73-
assert 4us >> 2us == 1us
74-
assert 4us >> 3us == 0us
72+
assert 4us >>> 1us == 2us
73+
assert 4us >>> 2us == 1us
74+
assert 4us >>> 3us == 0us
7575

7676
assert incr(0us) == 1us
7777
assert incr(0xffus) == 0us

stdlib/random.gr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ provide let nextUint32InRange = (random: Random, low: Uint32, high: Uint32) => {
155155
// Algorithm source: https://www.pcg-random.org/posts/bounded-rands.html#bitmask-with-rejection-unbiased-apples-method
156156
from Uint32 use *
157157
let range = high - low - 1ul
158-
let mask = lnot(0ul) >> clz(range | 1ul)
158+
let mask = lnot(0ul) >>> clz(range | 1ul)
159159
let mut x = nextUint32(random) & mask
160160
let mut iters = 0ul
161161
while (x > range) {
@@ -181,7 +181,7 @@ provide let nextUint64InRange = (random: Random, low: Uint64, high: Uint64) => {
181181
// Algorithm source: https://www.pcg-random.org/posts/bounded-rands.html#bitmask-with-rejection-unbiased-apples-method
182182
from Uint64 use *
183183
let range = high - low - 1uL
184-
let mask = lnot(0uL) >> clz(range | 1uL)
184+
let mask = lnot(0uL) >>> clz(range | 1uL)
185185
let mut x = nextUint64(random) & mask
186186
while (x > range) {
187187
x = nextUint64(random) & mask

stdlib/uint16.gr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ provide let (/) = (x: Uint16, y: Uint16) => {
158158
* @since v0.6.0
159159
*/
160160
@unsafe
161-
provide let (%) = (x: Uint16, y: Uint16) => {
161+
provide let rem = (x: Uint16, y: Uint16) => {
162162
let x = untagUint16(x)
163163
let y = untagUint16(y)
164164
let val = WasmI32.remU(x, y)
@@ -194,7 +194,7 @@ provide let (<<) = (value: Uint16, amount: Uint16) => {
194194
* @since v0.6.0
195195
*/
196196
@unsafe
197-
provide let (>>) = (value: Uint16, amount: Uint16) => {
197+
provide let (>>>) = (value: Uint16, amount: Uint16) => {
198198
// Trick: do not shift `value` right, just correct tag afterwards
199199
let x = WasmI32.fromGrain(value)
200200
let y = untagUint16(amount)

stdlib/uint16.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ Returns:
246246
|----|-----------|
247247
|`Uint16`|The quotient of its operands|
248248

249-
### Uint16.**(%)**
249+
### Uint16.**rem**
250250

251251
<details disabled>
252252
<summary tabindex="-1">Added in <code>next</code></summary>
253253
No other changes yet.
254254
</details>
255255

256256
```grain
257-
(%) : (Uint16, Uint16) -> Uint16
257+
rem : (Uint16, Uint16) -> Uint16
258258
```
259259

260260
Computes the remainder of the division of its operands.
@@ -298,15 +298,15 @@ Returns:
298298
|----|-----------|
299299
|`Uint16`|The shifted value|
300300

301-
### Uint16.**(>>)**
301+
### Uint16.**(>>>)**
302302

303303
<details disabled>
304304
<summary tabindex="-1">Added in <code>next</code></summary>
305305
No other changes yet.
306306
</details>
307307

308308
```grain
309-
(>>) : (Uint16, Uint16) -> Uint16
309+
(>>>) : (Uint16, Uint16) -> Uint16
310310
```
311311

312312
Shifts the bits of the value right by the given number of bits.

stdlib/uint32.gr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ provide let (/) = (x: Uint32, y: Uint32) => {
173173
* @since v0.6.0
174174
*/
175175
@unsafe
176-
provide let (%) = (x: Uint32, y: Uint32) => {
176+
provide let rem = (x: Uint32, y: Uint32) => {
177177
let xv = WasmI32.load(WasmI32.fromGrain(x), _VALUE_OFFSET)
178178
let yv = WasmI32.load(WasmI32.fromGrain(y), _VALUE_OFFSET)
179179
let ptr = newUint32(WasmI32.remU(xv, yv))
@@ -241,7 +241,7 @@ provide let (<<) = (value: Uint32, amount: Uint32) => {
241241
* @since v0.6.0
242242
*/
243243
@unsafe
244-
provide let (>>) = (value: Uint32, amount: Uint32) => {
244+
provide let (>>>) = (value: Uint32, amount: Uint32) => {
245245
let xv = WasmI32.load(WasmI32.fromGrain(value), _VALUE_OFFSET)
246246
let yv = WasmI32.load(WasmI32.fromGrain(amount), _VALUE_OFFSET)
247247
let ptr = newUint32(WasmI32.shrU(xv, yv))

stdlib/uint32.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,15 @@ Returns:
246246
|----|-----------|
247247
|`Uint32`|The quotient of its operands|
248248

249-
### Uint32.**(%)**
249+
### Uint32.**rem**
250250

251251
<details disabled>
252252
<summary tabindex="-1">Added in <code>next</code></summary>
253253
No other changes yet.
254254
</details>
255255

256256
```grain
257-
(%) : (Uint32, Uint32) -> Uint32
257+
rem : (Uint32, Uint32) -> Uint32
258258
```
259259

260260
Computes the remainder of the division of its operands.
@@ -350,15 +350,15 @@ Returns:
350350
|----|-----------|
351351
|`Uint32`|The shifted value|
352352

353-
### Uint32.**(>>)**
353+
### Uint32.**(>>>)**
354354

355355
<details disabled>
356356
<summary tabindex="-1">Added in <code>next</code></summary>
357357
No other changes yet.
358358
</details>
359359

360360
```grain
361-
(>>) : (Uint32, Uint32) -> Uint32
361+
(>>>) : (Uint32, Uint32) -> Uint32
362362
```
363363

364364
Shifts the bits of the value right by the given number of bits.

stdlib/uint64.gr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ provide let (/) = (x: Uint64, y: Uint64) => {
172172
* @since v0.6.0
173173
*/
174174
@unsafe
175-
provide let (%) = (x: Uint64, y: Uint64) => {
175+
provide let rem = (x: Uint64, y: Uint64) => {
176176
let xv = WasmI64.load(WasmI32.fromGrain(x), _VALUE_OFFSET)
177177
let yv = WasmI64.load(WasmI32.fromGrain(y), _VALUE_OFFSET)
178178
let ptr = newUint64(WasmI64.remU(xv, yv))
@@ -240,7 +240,7 @@ provide let (<<) = (value: Uint64, amount: Uint64) => {
240240
* @since v0.6.0
241241
*/
242242
@unsafe
243-
provide let (>>) = (value: Uint64, amount: Uint64) => {
243+
provide let (>>>) = (value: Uint64, amount: Uint64) => {
244244
let xv = WasmI64.load(WasmI32.fromGrain(value), _VALUE_OFFSET)
245245
let yv = WasmI64.load(WasmI32.fromGrain(amount), _VALUE_OFFSET)
246246
let ptr = newUint64(WasmI64.shrU(xv, yv))

0 commit comments

Comments
 (0)