continuations and state
Ruby continuations have been described as "going back in time" in your program, but that's not really true. You go back into the stack, but all your state remains the same. This ruby snippet:
Will produce the following output:
Note that the state variable keeps it's value. This is how you can do useful programming with continuations, even though you've jumped "back in time."
The next wierd thing, is that we don't get stuck in a loop. Notice "if continuation"? The second time we try to call the continuation, it is nil.
If you want, you can make a loop by doing the assignment inside the callcc block:
That will give you this output:
state = "label 1"
continuation = callcc { |c| c }
puts "state: #{state}"
state = "label 2"
continuation.call if continuationWill produce the following output:
state: label 1
state: label 2Note that the state variable keeps it's value. This is how you can do useful programming with continuations, even though you've jumped "back in time."
The next wierd thing, is that we don't get stuck in a loop. Notice "if continuation"? The second time we try to call the continuation, it is nil.
If you want, you can make a loop by doing the assignment inside the callcc block:
state = "label 1"
continuation = nil
callcc { |c| continuation = c }
puts "state: #{state}"
state = "label 2"
continuation.call if continuationThat will give you this output:
state: label 1
state: label 2
state: label 2
state: label 2
... (ad nauseam)
1. NARF 2. ruby-web 3. ???? 4. Profit!!!
Chad Fowler just linked to an article describing local maximums and career optimization. I guess Point C is the same as 3. ????.
Each time I sit down and think about Ruby vs other web environments, I see so much room for improvement. I thought the scary stuff was behind me, and then I started thinking about database support.
The next dip will be in sorting out the nitty gritty of database support. I think the main problem with DBI is driver support -- that'll teach me C for sure! Sorting out easy to use binary installers is also a pain.
Btw, Kirk Haines, developer of IOWA, pointed out that IOWA already has developed a Drb connection pool.
Each time I sit down and think about Ruby vs other web environments, I see so much room for improvement. I thought the scary stuff was behind me, and then I started thinking about database support.
The next dip will be in sorting out the nitty gritty of database support. I think the main problem with DBI is driver support -- that'll teach me C for sure! Sorting out easy to use binary installers is also a pain.
Btw, Kirk Haines, developer of IOWA, pointed out that IOWA already has developed a Drb connection pool.
DrbDatasource
I've been working out a contradiction in web apps:
Update: Ara Howard has released a postgres connection pool
- it's nice for each page to be independent, without having to worry about changes from other enviroments
- it's nice to have just a few cached database connections
Update: Ara Howard has released a postgres connection pool
