2021-07-12 07:51:10 you can always use the double xor to swap between two items without having an intermediate variable. 2021-07-12 07:56:27 double xor? 2021-07-12 12:06:53 eris[m]1: I'd assume it's the trick that lets you do something like `x = x ^ y`, `y = x ^ y` 2021-07-12 12:07:33 `x = x ^ y` 2021-07-12 12:10:01 ahh 2021-07-12 12:10:15 i wonder what that would look like on the stack 2021-07-12 13:05:08 kinda doesn't make sense on a stack, unless it's how you implement swap internally. 2021-07-12 13:08:39 what doesn't. 2021-07-12 13:08:59 the double xor trick for swapping two values without an intermediate. 2021-07-12 13:10:46 ah. yeah I mean.. the effect is the same. 2021-07-12 13:21:52 the limitation is of course the items cannot be the same because x ^ x = 0 2021-07-12 13:22:00 for x : bool 2021-07-12 13:26:41 they can be the same. x=1, y=1 ... x=x^y -> x=0 ... y=x^y -> y=1 .. x=x^y -> x=1... final state: x=1, y=1. 2021-07-12 13:27:55 oh I mean if x and y are the same storage location 2021-07-12 13:28:01 but yeah as long as they're separate it's fine 2021-07-12 13:28:09 ohh 2021-07-12 13:32:27 remexre: ^ would be a nice exercise to formally verify 2021-07-12 13:33:07 I would opt for a Hoare logic assertion, {{ X ::= a ; Y ::= b }} XOR_SWAP {{ X ::= b ; Y ::= a }} 2021-07-12 18:55:48 maw 2021-07-12 23:06:45 re maw