Knights of the Lambda Calculus

The Knights of the Lambda Calculus is a semi-fictional organization of expert LISP and Scheme hackers. The name refers to the lambda calculus, a mathematical formalism invented by Alonzo Church, with which LISP is intimately connected, and references the Knights Templar.
There is no actual organization that goes by the name Knights of the Lambda Calculus; it mostly only exists as a hacker culture in-joke. The concept most likely originated at MIT. For example, in the Structure and Interpretation of Computer Programs video lectures, one of the lecturers presents the audience with the button, saying they are now members of this special group. However, a “well-known LISPer” has been known to give out buttons with Knights insignia on them, and some people have claimed to have membership in the Knights.

Here is a local copy.
(via Wikipedia)

Why MIT switched from Scheme to Python

Costanza asked Sussman why MIT had switched away from Scheme for their introductory programming course, 6.001. This was a gem. He said that the reason that happened was because engineering in 1980 was not what it was in the mid-90s or in 2000. In 1980, good programmers spent a lot of time thinking, and then produced spare code that they thought should work. Code ran close to the metal, even Scheme — it was understandable all the way down. Like a resistor, where you could read the bands and know the power rating and the tolerance and the resistance and V=IR and that’s all there was to know. 6.001 had been conceived to teach engineers how to take small parts that they understood entirely and use simple techniques to compose them into larger things that do what you want.
But programming now isn’t so much like that, said Sussman. Nowadays you muck around with incomprehensible or nonexistent man pages for software you don’t know who wrote. You have to do basic science on your libraries to see how they work, trying out different inputs and seeing how the code reacts. This is a fundamentally different job, and it needed a different course.
So the good thing about the new 6.001 was that it was robot-centered — you had to program a little robot to move around. And robots are not like resistors, behaving according to ideal functions. Wheels slip, the environment changes, etc — you have to build in robustness to the system, in a different way than the one SICP discusses.
And why Python, then? Well, said Sussman, it probably just had a library already implemented for the robotics interface, that was all.

(via wingolog)

Literate Programming in Scheme

The release notes here for PLT Scheme 4.1.5 mention support for literate programming. Not being familiar with the term; I read more about it on Wikipedia here.
I have wanted in-code documentation generation tools to serve this purpose; but I have never succeeded with them. It had always felt like I was battling the intent of the tool. Even Eiffel’s notion of different views on code-as-documentation never quite fit for me. This approach is fascinating; it allows for you to tell a story about the code as you write the code. Having posted to the PLT list asking about it here; two folks replied with details on this style and Scheme.
PLT Scheme recently added literate programming support; documented here. One example of its application is in Chat Noir here; and the source code for it may be viewed here (Thanks Robby).
A tool for literate programming in Scheme called is schemeweb located here (Thanks Phil).

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)

How PLTCOLLECTS works in PLT Scheme

R6RS Scheme systems are composed of code artifacts that are either libraries or top-level-programs. Libraries simply map to directories. In PLT Scheme, you can configure the library search path by configuring the PLTCOLLECTS environmental variable.
Having configured it and not getting results that I had expected, I asked about what I was doing wrong and got a great explanation here. It is pasted below.

The path-list function does something that is common with environment variables that specify paths: you have a string of several paths, separated by a “:”, which are searched in order. In addition, an empty path means “splice the default here”. So you get:
“/foo:/bar” — look in /foo and then in /bar
“/foo:/bar:” — look in /foo, then in /bar, and then in the default
“:/foo:/bar” — look in the default, then /foo then /bar
“/foo::/bar” — look in /foo then the default, then /bar
The last example shows why it’s useful — it allows you to both override PLT collections, as well as specify collections that could be overriden by PLT collections. For example, the first is useful if you want to try patching libraries, and the second is useful if you want to add a library that is added to a later version of PLT and you want to use it now but not when you upgrade.
Finally, on windows, the path separator character is “;” instead of a colon. (And remember the possible pitfalls with backslashes, or just use forward slashes.)

Hopefully that detail gets added to the documentation; it wasn’t obvious from reading it.

Minor Scheme

Minor Schemeis an implementation of the Scheme programming language. Its planned features include: good performance, via:

  • just-in-time and ahead-of-time compilers generating native machine code
  • precise, generational garbage collection
  • full support for native system threads
  • full source-level debugging
  • a C API and a foreign function interface, for interfacing with C code
  • a module system which supports separate compilation and cross-compilation
  • a hygenic macro system

Jim Blandy