Undo?

2017-10-09 Thread Mr. Jonse via Digitalmars-d-learn
I requiring an undo feature in my code. Rather than go the regular route of using commands, I'm wondering if D can facilitate an undo system quite easily? We can think of an undo system in an app as a sort of recorder. The traditional method is to use commands and inverse-commands

Novel Undo

2017-09-16 Thread Mr Parks via Digitalmars-d-learn
Is there a way to integrate a undo/redo system in an already existing app without a huge amount of recording to support it? I.e., converting to using commands. I'd like to specify what is going to be modified and what needs to be done to restore the state. Given D's strong meta capab

Re: Undo?

2017-10-11 Thread Mr. Jonse via Digitalmars-d-learn
A simple(incomplete) undo system. I'm curious about the overhead. The idea is to wrap any system changes using the Add function. This function stores both the forward and backward state changes using delegates. By using forward, we call the action passed to set the data and backward

Re: Undo?

2017-10-12 Thread bitwise via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 02:36:56 UTC, Mr. Jonse wrote: I requiring an undo feature in my code. Rather than go the regular route of using commands, I'm wondering if D can facilitate an undo system quite easily? We can think of an undo system in an app as a sort of recorder.

Re: Undo?

2017-10-12 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 12 October 2017 at 02:18:49 UTC, Mr. Jonse wrote: A simple(incomplete) undo system. I'd think that for D you'd want to do type wrapping where a new type is created which saves changes and can manage an Undo tree. __gshared Data data = new Data(); auto undoa

Undo in D

2018-06-22 Thread DigitalDesigns via Digitalmars-d-learn
Is there any idiomatic undo designs in D that give a more natural implementation than the standard techniques?

Re: Undo in D

2018-06-23 Thread Basile B. via Digitalmars-d-learn
On Saturday, 23 June 2018 at 01:58:31 UTC, DigitalDesigns wrote: Is there any idiomatic undo designs in D that give a more natural implementation than the standard techniques? - The "stuff to undo" can be a forward range ("save" primitive, + assignable from a stored state

Re: Undo in D

2018-06-23 Thread Basile B. via Digitalmars-d-learn
On Saturday, 23 June 2018 at 14:06:08 UTC, Basile B. wrote: On Saturday, 23 June 2018 at 01:58:31 UTC, DigitalDesigns wrote: Is there any idiomatic undo designs in D that give a more natural implementation than the standard techniques? - The "stuff to undo" can be a forward ra

Re: Undo in D

2018-06-23 Thread bauss via Digitalmars-d-learn
On Saturday, 23 June 2018 at 01:58:31 UTC, DigitalDesigns wrote: Is there any idiomatic undo designs in D that give a more natural implementation than the standard techniques? There is the solution above, but there I've implemented something similar in Diamond. It's a little bit

Undo struct slicing by type-punning

2014-07-14 Thread ponce via Digitalmars-d-learn
Hi, I am porting C++ code that undo "Object Slicing" by casting const-references: http://en.wikipedia.org/wiki/Object_slicing My translation in D Code struct A { // stuff } struct B { A a; alias a this; // stuff } void myFunction(ref const(A) a

Re: Undo struct slicing by type-punning

2014-07-14 Thread ponce via Digitalmars-d-learn
Ok, solved it, I just use pointer casts and it seems to work when the struct is sliced. On Monday, 14 July 2014 at 13:23:57 UTC, ponce wrote: Hi, I am porting C++ code that undo "Object Slicing" by casting const-references: http://en.wikipedia.org/wiki/Object_slicing My transl

Re: Undo struct slicing by type-punning

2014-07-14 Thread Ali Çehreli via Digitalmars-d-learn
23:57 UTC, ponce wrote: >> Hi, >> >> I am porting C++ code that undo "Object Slicing" by casting >> const-references: >> http://en.wikipedia.org/wiki/Object_slicing >> >> >> My translation in D Code >> >> >> struct A

Re: Undo struct slicing by type-punning

2014-07-14 Thread ponce via Digitalmars-d-learn
On Monday, 14 July 2014 at 18:43:36 UTC, Ali Çehreli wrote: On 07/14/2014 10:35 AM, ponce wrote: > Ok, solved it, I just use pointer casts and it seems to work when the > struct is sliced. I think there is a terminology issue here. Slicing cannot be undone; once the object is sliced, the non-A

Re: Undo struct slicing by type-punning

2014-07-14 Thread ponce via Digitalmars-d-learn
On Monday, 14 July 2014 at 18:43:36 UTC, Ali Çehreli wrote: It is guaranteed by the language spec that yes, myFunction() takes an A by reference. However, you can't know where that A is coming from; so, the safety of that cast is up to you. Consider: void foo(A a) // <-- Already slice

Re: Undo struct slicing by type-punning

2014-07-14 Thread Ali Çehreli via Digitalmars-d-learn
On 07/14/2014 02:34 PM, ponce wrote: > On Monday, 14 July 2014 at 18:43:36 UTC, Ali Çehreli wrote: >> On 07/14/2014 10:35 AM, ponce wrote: >> >> > Ok, solved it, I just use pointer casts and it seems to work >> when the >> > struct is sliced. >> >> I think there is a terminology issue here. Slici