You could delegate the transaction list and other objects to a process specific variable. But the biggest problem with a copy approach is that all identity checks fail with the copied objectsBasically, what you are talking about is Software Transactional Memory.there *is* STM support for Pharo atalthough the last version there is from 2012, and there have been major changes to Pharosince then, so it probably doesn't work any longer.You could probably make a TransactionalObject class with a 'lastTransaction'instance variable, and a noteChange method that checks if lastTransaction ==Transaction current, and if not, pushes self -> self shallowCopy onto a stackinside Transaction and sets lastTransaction to Transaction current. Then toroll back a transaction, peel back original -> backup records from the stackand do original copyFrom: backup for each of them.Please don't ask me to think about combining this with concurrency.
On 31 July 2018 at 01:16, Peter Uhn��k <i.uhnak@gmail.com> wrote:Hi,is there some library or approach how to do transactions in pharo?And I don't mean database transactions, but directly in memory on Pharo objects... e.g.p := Person new.transaction do: [p name: 'Nobody'.p age: 70.] on: Error do: [transaction rollback.].self assert: p name equals: 'Nobody'.self assert: p age equals: 70.transaction do: [p name: 'Somebody'.p age: 1 / 0.] on: Error do: [transaction rollback.].self assert: p name equals: 'Nobody'.self assert: p age equals: 70.Any pointers appreciated.Thanks,Peter