Dreams.

Chris Tavares tavares at connix.com
Sun Jul 11 16:36:40 CEST 1999


Scott Dossey wrote:

> Okay, I am new to the newsgroup, but I thought I'd post something
> interesting that I've just started working on, and get some feedback.  I've
> been toying around with the idea of implementing "dreams" into the Python
> source code.
>
> What are dreams, you say?  Look at the following python code fragment for an
> idea, first of all, of how they are put into code:
>
> #START PSEUDOCODE FRAGMENT
> import sys
> import dreams
>
> aDream=dreams.dream()
> try:
>         #Insert code here.
> except:
>         aDream.wakeup()
>         sys.exit(1)
>
> aDream.realize()
> #END PSEUDOCODE FRAGMENT
>
> The code, at the location denoted by "#Insert code here." would run, but if
> an exception was thrown, it will have been as if the code had "happened in a
> dream".  No variables will have been changed/deleted.  Nothing will have
> changed from before the "dream" in terms of Python's variable state.
> Ideally, (but this is much harder), all file changes, all things that are
> "possible" to return to their original state, would be returned as well.
> (You can't take back network traffic).
>
> Dream.wakeup() would restore to the state before the dream, and continue
> execution from that line forward.  Dream.realize() would commit to the
> dream, stop saving change-state, and delete the change state it had already
> recorded.
>
>

[... SNIP ...]

>
> I'll take feedback in terms of ideas, problems, feasibility statements,
> flames,  whatever.  Most of all, I want help!  I think this would add a very
> interesting and useful feature to Python (as perhaps, a compile time option).
> Guido, I know you're out there, your feedback would be most appreciated,
> along with the feedback of any other Python maintainers.
>
> -Scott Dossey
> sdossey at armored.net, sdossey at openprojects.net

Scott,

What you're describing is transactional programing, which is used very heavily in
big database work. Basically, you "start a transaction", and do a bunch of stuff.
If everything works, you "commit" the transaction and all the changes you did are
made permanent. If anything goes wrong, you "roll back" the transaction and any
state is restored to before the transaction started.

I've never heard of the idea of integrating this directly into a programming
language. You might want to check out some database books for ideas.

-Chris






More information about the Python-list mailing list