Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timo's Motoko wishlist #3175

Open
Tracked by #3921
crusso opened this issue Mar 31, 2022 · 1 comment
Open
Tracked by #3921

Timo's Motoko wishlist #3175

crusso opened this issue Mar 31, 2022 · 1 comment

Comments

@crusso
Copy link
Contributor

crusso commented Mar 31, 2022

  • shift operators for Nat (and any other operators that are available for NatX/IntX but missing for Nat/Int) — See Shift primitives for Nat #3112
  • full matrix of conversions between fixed size NatX/IntX or at least between adjacent pairs of types (e.g. Nat8 <-> Nat16 etc).
  • NatX -> Blob operations, for easy access to bytes in little-endian and perhaps big-endian encoding.
  • Indexing for Blob value (blob[n] or Blob.sub(blob, n))
  • (Mutable blob type for writing efficient serializers, see perhaps Streaming Stabilization (emission) #3149)

@timohanke

@nomeata
Copy link
Collaborator

nomeata commented Mar 31, 2022

Now that we have inlining of prim wrappers (or I guess once we have that, not sure what the status is), maybe we can promise that two conversions via Nat/Int will always cancel out, instead of providing a full matrix? But may explicit is actually better.

@ggreif ggreif mentioned this issue Jun 3, 2022
4 tasks
mergify bot pushed a commit that referenced this issue Jun 21, 2022
Introduce two new primitives {`shiftLeft`, `shiftRight`}, both with signature `(Nat, Nat32) -> Nat`. This is hopefully helpful for #3175.

-------

- [x] `grep` for "TODO: use shift right instead"
- [x] `grep` for "TODO: use shift left instead"
- [ ] QuickChecks (but the tests are rather exhaustive already)
- [x] make the prims into calls? — 1672aa0

----------
## Further optimisation opportunities

- restructure the `lsh` code to reuse the 64-bit shift result to create the bignum ([see comment below](#3112 (comment)))
- `clz >= 33` as a criterion for compact
@crusso crusso mentioned this issue Apr 4, 2023
79 tasks
mergify bot pushed a commit that referenced this issue Aug 11, 2023
…4139)

Add type conversions between `Nat`s of adjacent sizes. Similarly for `Int`s.

Namely:
- `Nat8` <--> `Nat16`
- `Nat16` <--> `Nat32`
- `Nat32` <--> `Nat64`
- `Int8` <--> `Int16`
- `Int16` <--> `Int32`
- `Int32` <--> `Int64`

DX feature requested by Zhenya Usenko in the motoko working group and Timo:
partially #3175
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants