aiken-lang / aiken

A modern smart contract platform for Cardano
https://aiken-lang.org
Apache License 2.0
477 stars 94 forks source link

Probably shouldn't be using `usize` for uplc values #14

Closed MitchTurner closed 1 year ago

MitchTurner commented 2 years ago

Since usize is defined by the architecture of the machine, it's not consistent. It probably would be good to choose something that is more consistent, and hopefully the same as the Plutus Core spec.

rvcas commented 2 years ago

This is mostly fine. The only place we are using a usize in uplc is for the Debruijn index and I believe the Haskell code uses some equivalent type, in practice the number doesn't seem to get very big anyways. @MicroProofs do you recall why we used usize to represent DeBruijn(usize)?

MicroProofs commented 2 years ago

Debruijn is an exception where they used Word64, but in most cases values in the Haskell plutus used Integer which is a int of any size. To emulate this same behavior in rust we used isize and usize as appropriate. I am open to review individual cases to switch to a set size for where it makes sense. Right now we allowed for the maximum flexibility and are open to tightening that.

MicroProofs commented 2 years ago

Oops I made a duplicate issue #47.

But in there I describe a possible format to support any integer. Give it a look and let me know