Axe (@0xaxe) • Hey
Superfluid | https://github.com/ngmachado/
Publications
- xD
- `Yo, listen up, let me tell you 'bout some Solidity game`
`Where wrapping and unwrapping custom types is the name`
`Custom structs, enums, and arrays, that's the play`
`But when you wanna use 'em again, you gotta know the way`
`Wrap 'em up like a gift, that's the move`
`In a new type, easy to pass and approve`
`Unwrap 'em quick when you're ready to strike`
`Get the original type back, it's like dynamite`
`This is Solidity, it's not for the faint of heart`
`You gotta be aggressive, from the start`
`Wrap and unwrap, it's the technique that wins`
`It's a custom type game, and it's time to begin.`
- Custom Types as they are now should just be called aliases or "a.k.a" types.
- No operator overload
- No implicit wrap / unwrap when is clear what you want to do.
eg.
function add(FlowRate a, FlowRate b) internal pure returns (FlowRate) { <-- Return type defined
return FlowRate.wrap(FlowRate.unwrap(a) + FlowRate.unwrap(b));
^-- Why? ^--- operands are basic types, imply unwrap itself
}