aiken icon indicating copy to clipboard operation
aiken copied to clipboard

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

Open MitchTurner opened this issue 2 years ago • 3 comments

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.

MitchTurner avatar Jun 29 '22 06:06 MitchTurner

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)?

rvcas avatar Jun 29 '22 18:06 rvcas

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 avatar Jun 29 '22 18:06 MicroProofs

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

MicroProofs avatar Aug 26 '22 18:08 MicroProofs