KBD

Keith Devens .com

Tuesday, August 19, 2008 Flag waving
No battle plan ever survives contact with the enemy. – Field Marshall Helmuth Carl Bernard von Moltke

Archive: July 11, 2004

← July 10, 2004July 12, 2004 →

Daily link icon Sunday, July 11, 2004

ECMAScript for XML

I just noticed that ECMAScript for XML is now a standard.

It gives me the jeebies that XML should become a native data type in a programming language. Though, the statement I just made is sloppy because not only is the data type XML's "Infoset", not "XML" itself, but adding the Infoset to the language is only one of the pieces. The other is that you can represent XML itself natively in the language by actually typing XML code that the language recognizes, parses, and then represents as an Infoset or whatever.

Understanding continuations

Surprisingly, I think this continuation sandwich example (via the Perl 6 summary) has been more helpful in helping me understand continuations than anything else I've read so far. I already had a half-understanding, and this pushed me over to a three-quarters-understanding.

My understanding of continuations stands as follows: With closures, you create a function that wraps any lexicals in scope at the time which then travel along with the function wherever it goes. A continuation is similar, except rather than operating within the scope of a function, it operates on the scope of the entire program, wrapping all program state and carrying it around with it.

My main problem up until now has been that "The continuation can't just save all data associated with the program, that's crazy!". So I assume it must be part of some kind of copy-on-write scheme, where a continuation (probably similar to how closures wrap their lexicals) references the same variables as the main program does until one of those variables changes in the main program or in the continuation, at which point someone splits off a new variable that has the new value and is separate from the old variable.

The only issue is that I don't understand how this would work. Say you save 5 continuations at some point in the program. If you change a variable inside one of the continuations it splits off a new variable and doesn't share the same variable with the other four anymore. But, is the main program sort of like its own continuation, so if you change a variable in the main program it splits off a brand new one for itself? Furthermore, won't each of the 5 continuations have each of the preceeding continuations in its scope, and won't you therefore get really weird and complex cascading changes if you change something in one of the continuations around? Or, I suppose, it would do copy-on-write with the whole continuation? How the heck can the program reference everything without taking up gobs of memory? Finally, doesn't this take all kinds of complex program analysis to find out what changes and what doesn't in order to implement continuations efficiently?

Update: I asked for help over at Lambda the Ultimate and I've gotten at least one helpful response.

Update: Ian's written stuff on his weblog about this.

Joe Wilson

I'd just like to point out that I was right about Joe Wilson. Not that it was very hard to figure out. Previous posts here and here.

Update: Glenn Reynolds has more links. Oh, and this from earlier.

← July 10, 2004July 12, 2004 →
August 2008
SunMonTueWedThuFriSat
 12
3456789
10111213141516
17181920212223
24252627282930
31 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

Girls, please don't get breast implants

Wow... I'm almost embarrassed to​admit I'm a member of the female​gender, a...

Proud B-Cup: Aug 16, 2:59am

Spider solitaire

HELLO Keith, 
I did your​impossible game at fourth attempt​with score of 1...

NICOLA-ITA: Aug 14, 3:55am

Generated in about 0.06s.

(Used 7 db queries)

mobile phone