Two sids of the same coin: coroutines and streams

Jos asked here:

It seems to me that in many cases the same problem can be solved (for an eager evaluater) both by coroutines and by streams. Both solutions very well show the structure of the principal algorithm as might have been written with a lazy evaluator in mind. Which approach would be preferred in terms of efficiency (time and memory). May be you would like to address other aspects as well. One reason that makes me tend to choose streams, is that the latter seem better suited to automatic code generation from purely lazy code.

To which Matthais replied here:

It is indeed a well-known fact that streams and coroutines are two sides of the same coin. Talcott’s 1986 dissertation is the earliest theoretical treatment that I know.

Which Jim clarified here:

I believe the reference is to Carolyn Talcott’s dissertation “The essence of Rum: A theory of intensional and extensional aspects of Lisp-type computation”. Stanford, 1986. Unfortunately this is not available online, as far as I know.

TSPL 4th edition

The 4th edition of The Scheme Programming Language by R. Kent Dybvig is announced in the MIT Press catalog.

“The fourth edition has been substantially revised and expanded to bring the content up to date with the current Scheme standard, the Revised6 Report on Scheme. All parts of the book were updated and three new chapters were added, covering the language’s new library, exception handling, and record-definition features.”

The paper catalog gives a date of July 2009. The online catalog gives a date of September 2009.

http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&tid=11984

(via comp.lang.scheme)

Tendrils in Scheme

Here is an art piece by Tom De Smedt written in NodeBox (Python) :

http://www.nodebox.net/code/index.php/Tendrils

It is in turn based on work done in Processing by a group ART+CODE.

Ported to Abstracting:

http://github.com/dharmatech/abstracting/blob/master/examples/tendril

Although Abstracting is OpenGL based, I made a NodeBox compatibility library which allowed for a straightforward port.

Here is a rendering performed by Abstracting/Ypsilon :

tendrils-ypsilon-2009-04-07.png

Ed

I wonder if that is something that Script-Fu would do well?

(via comp.lang.scheme)

chibi-scheme 0.1

An initial preview release of Chibi-Scheme is available at

http://synthcode.com/scheme/chibi-scheme-0.1.tgz

Smaller than TinyScheme, faster than a speeding Guile, able to leap tall vectors in a single bounds check, with native hygiene to boot!

WARNING: Do not use Chibi-Scheme!

Seriously, there are real Scheme compilers out there. The author of Chibi-Scheme was working on one himself before starting this silly project, and will likely continue to work on it for years to come. But sometimes we all just want to release something.

There seems to be a disturbing trend, however, of people taking toy Scheme interpreters seriously. It can’t be for ease of use, because the serious compilers all have the most friendly FFI’s. It can’t be for the small memory footprint, because the difference between a 100k and 2MB program text will be dwarfed by the runtime memory, and all of the real implementations have much more efficient memory usage. But time and again you’ll find TinyScheme crop in in bizarre places, which leads one to wonder how much of a bad name is Scheme getting by being so often represented by one of the slowest language implementations on the planet?

So Chibi-Scheme exists as a better toy implementation. It’s a very small but mostly complete R5RS Scheme implementation using a reasonably fast custom VM. Chibi-Scheme tries as much as possible not to trade its small size by cutting corners, and provides full continuations, both low and high-level hygienic macros based on syntactic-closures, string ports and exceptions. It also has optional immediate symbols, just to be quirky.

But don’t use Chibi-Scheme. Don’t use toy Scheme implementations at all. But if you really want a toy… well, then perhaps Chibi-Scheme 0.3 or so may be right for you.

[On a more serious note, I do want to hold this up as an example of how extremely simple and natural it is to implement syntactic-closures compared to alternatives such as syntax-case. The whole macro implementation is about 25 lines of low-level C code (modulo the extra lines I’ll have to add later for bug fixes), as opposed to say the 4000 or so lines of Scheme for psyntax.]

– Alex

(via comp.lang.scheme)

WisperWeb: Scheme in the browser

Here is a blog about the WisperWeb application framework.

The name evolved from my use of Lisp as a browser scripting language – “Web” + “Lisp” merged to “Wisp” and a search of available domain names resulted in the choice of ”WisperWeb”.

There are several themes that I will address in this blog: o the technology and impact of Google’s Application Engine o using GWT/GXT to build programs for the browser environment o why Lisp is an ideal Web scripting language o how XMPP instant messaging (soon be be available for the AppEngine) can be used to build browser-based, shared applications

WisperWeb has been developed over the past year and is now in the early phases of deployment. My posts will primarily address the challenges and benefits of building “real world” solutions using these technologies.

– Peter Fisk

R6RS records and exports

In this post I asked:

Records conveniently generate a constructure and getters and setters for you.

Is there a way to conveniently export all these generated functions?

I am thinking of generating a helper function so I can copy and paste the exports; this is not ideal of course.

Aziz posted the following solution which works fine on PLT with Andrerui’s fix. I added code to make it in a standard library location:

redefine-record.sls


#!r6rs

;;;; Via comp.lang.scheme "R6RS records and exports"
;;;; By Aziz

;;; redefine-record.sls

(library
 (redefine-record redefine-record)
 (export redefine-record-type)
 (import (rnrs))

 (define-syntax redefine-record-type
   (syntax-rules ()
     [(_ record-name)
      (begin
        (define-syntax m
          (lambda (x)
            (define (fmt s1 stx . s*)
              (datum->syntax stx
                             (string->symbol
                              (apply string-append
                                     s1
                                     (symbol->string (syntax->datum stx))
                                     s*))))
            (define (enumerate i j)
              (if (= i j) '() (cons i (enumerate (+ i 1) j))))
            (syntax-case x ()
              [(_ ctxt)
               (let* ([rtd (record-type-descriptor
                            record-name)]
                      [f* (record-type-field-names rtd)]
                      [rcd (record-constructor-descriptor
                            record-name)])
                 (with-syntax ([make-T (fmt "make-" #'ctxt)]
                               [T? (fmt "" #'ctxt "?")]
                               [(n* (... ...))
                                (enumerate 0 (vector-length f*))]
                               [#(T-ref* (... ...))
                                (vector-map
                                 (lambda (x)
                                   (fmt "" #'ctxt "-" (symbol->string
                                                       x)))
                                 f*)])
                   #'(begin
                       (define make-T
                         (record-constructor
                          (record-constructor-descriptor
                           record-name)))
                       (define T?
                         (record-predicate
                          (record-type-descriptor
                           record-name)))
                       (define T-ref*
                         (record-accessor
                          (record-type-descriptor record-name)
                          n*))
                       (... ...))))])))
        (m record-name))])))


t1.sls


#!r6rs

;;;; Via comp.lang.scheme "R6RS records and exports"
;;;; By Aziz

;;; t1.sls

(library
 (redefine-record t1)
 (export M)
 (import (rnrs))

 (define-record-type M
   (fields x y z)))


t2.ss


#!r6rs

;;;; Via comp.lang.scheme "R6RS records and exports"
;;;; By Aziz and Andreuri

;;; t2.ss

(import (rnrs) (for (redefine-record t1) expand run) (redefine-record redefine-record))

(redefine-record-type M)

(define x (make-M 12 13 14))
(display (list x (M? x) (M-x x)))
(newline)

Run this to see it work:


plt-r6rs t2.sls
=> {#(struct:M 12 13 14) #t 12}

win-control

OLE, Internet Explorer and raw windows automation library for Gambit-C on Windows platforms

Inspired by Watir on Ruby, this library brings the same capabilities and more to the high-performing Gambit Scheme implementation. Now you can write automated test scripts or automate Windows application tasks in beautiful Scheme code and compile it all into a standalone exe file.

(via comp.lang.scheme)