Generators in Scheme

The Scheme Cookbook is starting to attract some new contributors. Daniel Silva contributed an implementation of iterators similar to Python's iterators, which was timely because I've been thinking about the same thing. Ruby Iteration Styles has a comparison of Python iteration style to Ruby iteration style, focusing on a distinction between internal and external generators. To compare apples to apples, here are the three examples that should print "1 1 2 3 5 8 13 21 34 ", starting with Scheme:
 (define-gen (fib )
               (let loop ((x 0)
                          (y 1))
                 (yield y)
                 (loop y (+ x y))))
  (define f (fib))
  (do ((i 0 (+ i 1)))
     ((= i 9) '())
     (display (send f next)) (newline))
 
Now, the Ruby version.
 def fibs(n)
     x = 0
     y = 1
     n.times do
       x, y = y, x + y
       yield(x)
     end
   end
   
   fibs(9) { |x| print x, " "}
 
And the Python version:
def fib():
     x = 0
     y = 1
     while 1:
         x, y = y, x + y
         yield x
 
 g = fib()
 for i in range(9):
     print g.next() ,
 
Honestly, the main difference is that Python and Ruby have nicer syntactic sugar around their looping constructs (range in Python and times in Ruby). However, Scheme has a facility similar to range available in SRFI-42.

— Gordon Weakliem at permanent link

Dynamic Compilation, Reflection, Customizable Apps

My colleagues Eric Terrell and David Scofield have an article in the October 2004 Dr. Dobbs' Journal entitled Dynamic Compilation, Reflection, Customizable Apps. The summary reads:
...talks about giving users what they want when they want it, by developing applications that offer user-created toolbar buttons and menu items that can launch custom features written in dynamically compiled C# or Visual Basic.NET
Eric and David are great programmers and great guys, too, I'm looking forward to reading this.

— Gordon Weakliem at permanent link