18 Feb 2009

Steering Scheme

posted by matthias

Election time is here again. A couple more days and the Scheme community will have a set of new steer-ers.

What should we want from a steering committee?

I have argued at this place before that good language design needs a feedback loop. Language designers write down specs; language implementers translate those specs into compilers and interpreters; programmers use these implementations to produce useful software. The loop comes in when implementers inform designers of flaws, inconsistencies, mistakes, errors, and other internal consistency problems in the specs. This is clearly happening with R6RS, and it is good. Implementers are a biased bunch, however. After all, they work on just one kind of program, and in a highly specialized domain that has been mined for a long time. How can you trust them? [*]

The loop becomes truly useful when people write large software systems (not just compilers, because they really are special cases!) and find that the language fails them in some way. Such failures can come in a number of flavors. For a document such as R6RS, we should hope that programmers can discover problems with porting systems that are apparently due to ambiguities, flaws, mistakes, roaches in the actual document (as opposed to a specific implementation).

So what does this have to do with the steering committee?

The last thing we want from a steering committee is a radical commitment to change (whatever it may be); a prejudice concerning R6RS; a closed mind about the size of “Scheme” (it’s too large, it’s too small); a willingness to steer without making observations. A steering committee of overbearing curmudgeons is not what we want.

What we do want is a committee that is willing to figure out how the listening is going to happen; how we can possibly finance a systematic way of listening (writing NSF grants, anyone?); how the feedback is best channeled into language design.

Let’s hope we get such a steering committee. The Scheme community deserves it.

[*] No I am not naive enough to think that language implementers don’t design languages, and that implementers don’t program systems other than implementations. I am just skeptical that it is easy for them to separate out their various roles in an objective manner, even if many of them are able to think at several different levels about programs.

more →

14 Feb 2009

New Contract-Related Features

posted by Stevie

In SVN I’ve added three new major features that involve contracts. One allows for more fine-grained control of contracts, and the other two allow for the use of contracts with signatures and units.

Contract Regions

Contract regions allow the programmer to protect a region of code with a contract boundary. In addition to the wrapped code, the programmer also provides a name for the region which is used in blame situations and a list of exported variables which can either be protected with contracts or unprotected. The region provides a true contract boundary, in that uses of contracted exports within the region are unprotected. Contract regions are specified with the with-contract form. The following contract region defines two mutually recursive functions:

(with-contract region1
 ([f (-> number? boolean?)]
  [g (-> number? boolean?)])
 (define (f n) (if (zero? n) #f (g (sub1 n))))
 (define (g n) (if (zero? n) #t (f (sub1 n)))))

The internal calls to `f` and `g` are uncontracted, but calls to `f`and `g` outside this region would be appropriately contracted.  First-order checks are performed at the region, so the
following region:

(with-contract region2
 ([n number?])
 (define n #t))

results in the following error:

(region region2) broke the contract number? on n; expected <number?>, given: #t

Notice that the blame not only gives the name of the region, but describes what type of contract boundary was involved.

For contracting a single definition, there is the define/contract form which has a similar syntax to define, except that it takes a contract before the body of the definition.

To compare the two forms, the following two definitions are equivalent:

(with-contract fact
 ([fact (-> number? number?)])
 (define (fact n)
   (if (zero? n) 1 (* n (fact (sub1 n))))))

(define/contract (fact n)
 (-> number? number?)
 (if (zero? n) 1 (* n (fact (sub1 n)))))

First order checks are similarly performed at the definition for define/contract, so

(define/contract (fact n)
 (-> number?)
 (if (zero? n) 1 (* n (fact (sub1 n)))))

results in

(function fact) broke the contract (-> number?) on fact; expected a procedure that accepts no arguments without any keywords, given: #<procedure:fact>

Signature Contracts

In addition to contract regions, units are also now contract boundaries. One way to use contracts with units is to add contracts to unit signatures via the contracted signature form.

(define-signature toy-factory^
   [build-toys (-> integer? (listof toy?))]
   [repaint    (-> toy? symbol? toy?)]
   [toy?       (-> any/c boolean?)]
   [toy-color  (-> toy? symbol?)])))

Notice that contracts in a signature can use variables listed in the signature.Now if we take the following implementation of that signature:

(define-unit [email protected]
 (export toy-factory^)

 (define-struct toy (color) #:transparent)

 (define (build-toys n)
   (for/list ([i (in-range n)])
     (make-toy 'blue)))

 (define (repaint t col)
   (make-toy col)))

We get the appropriate contract checks on those exports:

> (define-values/invoke-unit/infer [email protected])
> (build-toys 3)
(#(struct:toy blue) #(struct:toy blue) #(struct:toy blue))
> (build-toys #f)
top-level broke the contract (-> integer? (listof toy?))
 on build-toys; expected >, given: #f

As before, uses of contracted exports inside the unit are not checked.

Since units are contract boundaries, they can be blamed appropriately. Take the following definitions:

(define-unit [email protected]
 (import toy-factory^)
 (let ([toys (build-toys 3)])
   (repaint 3 'blue)))

(define-compound-unit/infer [email protected]
 (import) (export)
 (link [email protected] [email protected]))
When we invoke the combined unit:> (define-values/invoke-unit/infer [email protected])
(unit [email protected]) broke the contract
 (-> toy? symbol? toy?)
on repaint; expected >, given: 3

Unit Contracts

However, we may not always be able to add contracts to signatures. For example, there are many already-existing signatures in PLT Scheme that one may want to implement, or a programmer may want to take a unit value and add contracts to it after the fact.

To do this, there is the unit/c contract combinator. It takes a list of imports and exports, where each signature is paired with a list of variables and their contracts for each signature. So if we had the uncontracted version of the toy-factory^ signature:

(define-signature toy-factory^
 (build-toys repaint toy? toy-color))

the following contracts would be appropriate for a unit that imports nothing and exports that signature:

(unit/c (import) (export))
(unit/c (import) (export toy-factory^))
 (export (toy-factory^
          [toy-color (-> toy? symbol?)])))
 (export (toy-factory^
          [build-toys (-> integer? (listof toy?))]
          [repaint    (-> toy? symbol? toy?)]
          [toy?       (-> any/c boolean?)]
          [toy-color  (-> toy? symbol?)])))

Unit contracts can contain a superset of the import signatures and a subset of the export signatures for a given unit value. Also, variables that are not listed for a given signature are left alone when the contracts are being added.

Since the results of applying unit/c is a new unit, then adding a contract can cause link inference to fail. For example, if we change the definition of [email protected] above to

(define/contract [email protected]
  (export (toy-factory^
           [build-toys (-> integer? (listof toy?))]
           [repaint    (-> toy? symbol? toy?)]
           [toy?       (-> any/c boolean?)]
           [toy-color  (-> toy? symbol?)])))
   (export toy-factory^)

   (define-struct toy (color) #:transparent)

   (define (build-toys n)
     (for/list ([i (in-range n)])
       (make-toy 'blue)))

   (define (repaint t col)
     (make-toy col))))

Then when we try to combine it with the [email protected] unit, we get:

define-compound-unit/infer: not a unit definition in: [email protected]

One way to solve this is to use define-unit-binding to set up the static information for the new contracted value. Another possibility for unit definitions is to use define-unit/contract:

(define-unit/contract [email protected]
 (export (toy-factory^
          [build-toys (-> integer? (listof toy?))]
          [repaint    (-> toy? symbol? toy?)]
          [toy?       (-> any/c boolean?)]
          [toy-color  (-> toy? symbol?)]))

 (define-struct toy (color) #:transparent)

 (define (build-toys n)
   (for/list ([i (in-range n)])
     (make-toy 'blue)))

 (define (repaint t col)
   (make-toy col)))

More about these features can be found in the Reference, and a short section about signature and unit contracts has been added to the Guide.

more →

29 Jan 2009

CfP: Scheme Workshop 2009!

posted by John Clements

SCHEME AND FUNCTIONAL PROGRAMMING WORKSHOP 2009: Cambridge, Massachusetts: August 22, 2009: call for papers: http://www.schemeworkshop.org/2009/:

The Scheme and Functional Programming Workshop showcases research and experience related to Scheme, and more broadly to all aspects of functional programming.

Areas of interest include:

  • Language Design, Type Systems, Theory

  • Program Development Environments, Education

  • Agile Methodologies, Lightweight Software Engineering

  • Applications, Implementation, and Experience

  • SRFIs!

In addition to technical papers on matters of programming-language research, we encourage submissions that present experience or innovation with a particular project. The key criterion for any paper—technical or not—is that it makes a contribution from which other practitioners can benefit.


Dates are firm, and will not be extended. Please plan accordingly.

  • Submission Deadline: June 5, 2009 (FIRM)

  • Author Notification: June 26, 2009

  • Final Papers Due: July 24, 2009

  • Workshop: August 22, 2009

Program Committee::

  • John Clements, Cal Poly State University (organizer & chair)

  • Dominique Boucher, Nu Echo

  • Abdulaziz Ghuloum, Indiana University

  • David Herman, Northeastern University

  • Shriram Krishnamurthi, Brown University

  • Matthew Might, University of Utah

  • David Van Horn, Northeastern University

Publication Policy::

Submitted papers must have content that has not previously been published in other conferences or refereed venues, and simultaneous submission to other conferences or refereed venues is unacceptable.

Publication of a paper at this workshop is not intended to replace conference or journal publication, and does not preclude re-publication of a more complete or finished version of the paper at some later conference or in a journal.

Submission Instructions::

Your submissions should be no longer than 12 pages, including bibliography and appendices. Papers may be shorter than this limit, and the Program Committee encourages authors to submit shorter papers where appropriate.

The conference web page (URL above) contains detailed formatting instructions and LaTeX support files.

Submit your papers using the Continue 2.0 submission server, at the URL:


We look forward to reading your papers!

more →

21 Jan 2009

PLT Scheme v4.1.4

posted by Eli Barzilay

PLT Scheme version 4.1.4 is now available from http://plt-scheme.org/

  • New libraries include scheme/package' (for nestable static modules) andffi/objc’ (support for Objective-C).

  • New teaching support includes a “universe.ss” teachpack for connecting “worlds” over a network.

  • Redex now supports automatic test-case generation. Specify a predicate that should hold of your reduction system, and Redex will attempt to falsify it. See ‘redex-check’ in the manual for more details.

  • Improvements to the run-time system include better and more reliable memory-limit tracking, function contracts that preserve tail recursion in many cases, native debugging backtraces on x86_64, and performance improvements.

  • Improved libraries include enhancements to scheme/sandbox', better handling of zero-sized matches byregexp-split’ and friends, an equal>' interface for specifying equality on class instances (and more general support for attaching properties to interfaces), equality (viaequal>’) for image objects, and refinements to `scheme/foreign’ to support atomic operations and function-pointer conversions.

[Note that mirror sites can take a while to catch up with the new downloads.]

Feedback Welcome.

more →

24 Nov 2008

Simple GnuPLoTting

posted by vyzo

gnuplot is a very powerful and widely used interactive data plotting program. It can generate two-dimenational and three-dimensional surface plots, either on screen or print to files with a wide-array of supported formats. If you are not familiar with it, you can get an idea of its capabilities here

A new package, gnuplot.plt, is now available on planet which allows you to programmatically interact with gnuplot processes and generate plots on the fly. The package provides a simple interface that abstracts gnuplot’s quirky syntax and takes care of data marshalling using temporary files.

Without further ado, here is to every computer scientist’s favorite growth curves:

(require (planet vyzo/gnuplot))
(define gplot (gnuplot-spawn))
(define data 
   (build-list 90
     (lambda (x) 
       (let ((x (add1 (/ x 10.))))
         (list x (log x) (* x (log x)) (expt x 2) (expt 2 x)))))))
;; png output options
(define png '(png enhanced transparent font (str arial)))
;; on screen plot
(gnuplot-set gplot '(title (str "growth curves")))
(gnuplot-plot gplot 
  #:range '(() (1 1000))
  (gnuplot-item data '(using (seq: 1 1) title (str "x") with line))
  (gnuplot-item data '(using (seq: 1 2) title (str "log(x)") with line))
  (gnuplot-item data '(using (seq: 1 3) title (str "xlog(x)") with line))
  (gnuplot-item data '(using (seq: 1 4) title (str "x^2") with line))
  (gnuplot-item data '(using (seq: 1 5) title (str "2^x") with line)))
;; replot to png
(gnuplot-hardcopy gplot "/tmp/grow.png" #:term png)
;; redo with logscale
(gnuplot-set gplot '(logscale y))
(gnuplot-replot gplot)
(gnuplot-hardcopy gplot "/tmp/loggrow.png" #:term png)
more →

21 Nov 2008

PLT Scheme v4.1.3

posted by Eli Barzilay

PLT Scheme version 4.1.3 is now available from http://plt-scheme.org/ This is a bug-fix release.

Notable changes:

  • Web Server:
  • Documentation rewritten to separate servlet APIs and server extension APIs
  • HTTPS supported on the “plt-web-server” command-line with "—ssl" option
  • Stateless servlets supported in default configuration through ’stateless interface-version
  • `web-server/servlet-env’ supports top-level servlets through #:servlet-path
  • Servlets are served from anywhere in the htdocs directory by default
  • A template system based on the Scribble syntax has been added, see web-server/templates in the documentationAnd many other internal modifications to make extension easier!

[Note that mirror sites can take a while to catch up with the new downloads.]

Feedback Welcome.

more →

28 Oct 2008

PLT Scheme v4.1.2

posted by Eli Barzilay

PLT Scheme version 4.1.2 is now available from http://plt-scheme.org/ This is a bug-fix release.

[Note that mirror sites can take a while to catch up with the new downloads.]

Feedback Welcome.

more →

06 Oct 2008

Web Application Development in PLT Scheme

posted by Jay McCarthy

Many users often post to the plt-scheme mailing list asking for introductions to Web application development in PLT Scheme. They’ve heard of the continuation-based PLT Web Server and want a gentle introduction. Unfortunately, there has been a distinct lack of good documentation and tutorials for the server. Taking the cue from two users: Jens Axel Soegaard and David Reynolds, we’ve written a tutorial with Danny Yoo.

The tutorial is available at http://docs.plt-scheme.org/continue/index.html. It walks through the creation of a blog application, introducing features slowly and culminates in an SQL-backed database for the posts. Of particular interest, is the fast start servlet setup based on the Instaservlet package from Untyped.

Please take a look and pass along this as a pointer to those who may be interested in PLT Scheme.

more →

05 Oct 2008

PLT Scheme v4.1.1

posted by Eli Barzilay

PLT Scheme version 4.1.1 is now available from http://plt-scheme.org/Notable changes:

  • web-server: New servlet development tutorial; quick launching of servlets from DrScheme via the `web-server/insta’ language; new form abstraction through formlets.

  • misc: mzc can “decompile” bytecode files; `#lang’ lines wired to the top of DrScheme’s definition window; improved searching in DrScheme; some foreign interface extensions.[Note that mirror sites can take a while to catch up with the new downloads.]

Feedback Welcome.

more →

12 Aug 2008

PLT Scheme v4.1

posted by Eli Barzilay

PLT Scheme version 4.1 is now available from http://plt-scheme.org/

  • DrScheme changes:
    • The Module language now has an automatically inserted #lang declaration, so the interactions window is available right away for new windows.
    • Searching is now interactive (see the manual for details).
    • Memory limits are now enabled by default.
  • Typed Scheme supports a novel type checking mechanism for homogeneous and heterogeneous variable-arity function definitions and applications.

  • Redex (a domain-specific language for testing operational semantics) is now included in the distribution. See also [redex.plt-scheme.org](http://redex.plt-scheme.org/).

  • Lots of improvement to the documentation, including: better searching, table-of-contents, and language-sensitive help (in the teaching languages).

  • The world.ss teachpack no longer supports end-of-time, only stop-when.

  • MzScheme has now a logging facility, search the documentationfor “logger” for more details.

  • Bug fixes:
    • begin in R5RS (and derived languages),
    • #lang planet,
    • eval works with phases.

Feedback Welcome.

more →

Made with Frog, a static-blog generator written in Racket.
Source code for this blog.