endo icon indicating copy to clipboard operation
endo copied to clipboard

-0 should round trip through pass-style but remain equiv to 0 at patterns level

Open erights opened this issue 2 years ago • 1 comments

See https://github.com/ocapn/ocapn/issues/58#issuecomment-1570820042

erights avatar May 31 '23 19:05 erights

Lexicographic order imposes a surprising constraint:

compareRank(-0, 0) === 0;
compareRank([0, 1], [0, 2]) < 0;
compareRank([0, 1], [-0, 2]) < 0;

Therefore

encodePassable([0, 1]).body < encodePassable([-0, 2]).body

Therefore, in a compositional encoding

encodePassable(0).body === encodePassable(-0).body

Therefore, the distinction between -0 and 0 must be outside the body, just as the encoding of the details of remotables, promises, and errors must be outside the body, in order to not break lexicographic order in the same way. See encodeThing currently at https://github.com/endojs/endo/blob/19180f6f88619b2e11bb90a7a1d90790709bf8e2/packages/marshal/test/test-encodePassable.js#L43-L47

erights avatar May 31 '23 20:05 erights