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.

Understanding PLT Redex

The formal semantics of R6RS are described using PLT Redex. I don’t understand this field of study or where to start so I asked about it on the PLT discussion list and Robby replied here:

Start by reading the introduction to the formal semantics. Then download it and look at the README file (there are some examples in there to get you going).
If you’re interested in learning more about the style of semantics, as background on the R6 semantics, you can start with the redex web site and ask questions here. There is a book that should be coming out in a few months that might also be helpful.

— Robby
Jos also explained here:

Redex is a tool that allows:
1: the description of the grammar of a language
2: the description of how an expression of that language is to be reduced to the value of that expression (reduction relation)
3: after having done steps 1 and 2, redex (in casu procedures traces and apply-reduction-relation) can show you how an expression is reduced to its value.
Although Redex is far more general than just a tool to play with Lambda Calculus (LC) and Combinatory Logic (CL), my path was the following:
0: Imperative programming.
1: The Little LISPer, which is a great primer before glancing into 4. (about recursion, not really a book about programming, imho)
2: Greg Michaelson, An Introduction to Functional Programming through Lambda Calculus (not a masterpiece, but easy to read)
3: Playing with Scheme (particularly preparing lots of interpreters.
4: 1984. The Lambda Calculus, Its Syntax and Semantics, Vol. 103 in Studies in Logic and the Foundations of Mathematics. North-Holland. ISBN 0-444-87508-5. Not easy but very comprehensive.
5: SICP (transformation to continuatian passing style and storage passing style)
6: Redex, which allows me to check my understanding of LC and CL.
You can regard LC and CL as the ultimate mathematical abstractions of programming languages. In fact LC consists of the ultimate lambda and applications only, nothing else. CL goes even further. It has applications only, no lambda, just a few primitive functions (possibly only one) Yet CL and LC can be proven to incorporate all “definable functions”. These are not programming languages for practical use, They are formal mathematical systems of outraging beauty. If you want to make working programs, you’d better not follow my path, I think.
LC is an important piece of mathematics for the formal study of the properties of real life programming languages. It is used extensively in scientific studies on real life programming languages. Scheme can rather easily be described with mathematical precision in terms of LC. IIRC Algol60 has been described in terms of LC too. As an example, the semantical description of Scheme-R6RS is based on knowledge based on LC.

— Jos

Unhygienic macros inside of unhygienic macros are difficult

In this post; Ryan explains why unhygienic macros inside of unhygienic macros are often difficult.

;; the working if-it & when-it
(define-syntax (if-it stx)
  (syntax-case stx ()
    ((if-it test? then else)
     (with-syntax ((it (datum->syntax #'if-it 'it)))
       #'(let ((it test?))
           (if it then else))))))
(define-syntax (when-it stx)
  (syntax-case stx ()
    ((~ test? exp exp2 ...)
     (with-syntax ((it (datum->syntax #'~ 'it)))
       #'(let ((it test?)) (when it exp exp2 ...))))))
;; the non-working cond-it
(define-syntax (cond-it stx)
  (syntax-case stx (else)
    ((cond-it (else exp exp2 ...))
     #'(begin exp exp2 ...))
    ((cond-it (test? exp exp2 ...))
     #'(when-it test? exp exp2 ...))
    ((cond-it (test? exp exp2 ...) cond1 cond2 ...)
     #'(if-it test? (begin exp exp2 ...)
              (cond-it cond1 cond2 ...)))))

When ‘cond-it’ expands and produces an ‘if-it’ expression, the ‘if-it’ is marked by the macro expander as coming from a macro. That means its lexical context is different from the ‘it’ variables in the branches. That means that the ‘it’ variable binding produced by ‘if-it’ does not capture the ‘it’ references in the branches.

— Ryan

Adding a gutter to DrScheme

I had asked about how to add a gutter with line numbers to DrScheme, and Robby explained one approach here.

#lang scheme/gui
(require (lib "framework.ss" "framework")
         (lib "etc.ss"))
(define f (new frame:basic% [label ""] [width 500] [height 600]))
(define hp (new horizontal-panel% [parent (send f get-area-container)]))
(define gutter-text (new scheme:text%))
(define gutter-ec (new editor-canvas%
                       [parent hp]
                       [style '(hide-vscroll)]
                       [editor gutter-text]
                       [stretchable-width #f]
                       [min-width 60]))
(define text (new scheme:text%))
(define ec (new editor-canvas% [parent hp] [editor text]))
(send text load-file (build-path (collection-path "drscheme")
                                 "private" "rep.ss"))
(for-each
 (λ (n) (send gutter-text insert (format "~a\n" n)))
 (build-list (send text last-paragraph) add1))
(send gutter-ec scroll-to 0 0 0 0 #t)
(send f show #t)

Programming gerbils: Distributed programming with PLT-Scheme

Next Boston Lisp Meeting: Monday February 23th 2009 at 1800 at MIT 34-401B
Dimitris Vyzovitis will give a talk about Programming gerbils: Distributed programming with PLT-Scheme.
vyzo will talk about gerbil, a little language for distributed programming using PLT-Scheme. Gerbil is a macro language that provides facilities for actor-based distributed programs and transparent network simulation.
vyzo is a PhD student at the MIT Media Lab who suffers from a severe scheme addiction.
His website is at http://web.media.mit.edu/~vyzo/

(via PLT)

About the PLT Scheme Source Search

John asked about the status of the PLT Scheme PLaneT source search system here; to which Jens replied here and referenced this post. This post has information about why you might want to use the search engine (find out where set! is abused!) and also links to all of his posts about the development of the engine itself.
Jens mentions that he is not able to focus on maintenance at the moment; but if anyone is interested he would be happy to pass them the code.

New PLT Scheme DEV Mailing List

PLT Scheme has a new development related mailing list. The focus of this list is on the development of the PLT Scheme system itself rather than the utilization of PLT Scheme.
Here is a link to the post.
Here is a link to the signup page for the list.
Here is further clarification on who might be interested in this list, as plucked from the “Welcome” email from the list:

Welcome to the plt-dev@list.cs.brown.edu mailing list! This list is for discussions on the implementation and development of PLT Scheme. It is aimed at people who are interested in contributing to PLT Scheme, or who are interested in the implementation of PLT Scheme. However, it is not for general discussion of Scheme, PLT Scheme, or programming — please use the plt-scheme list for those.

How to handle large data in DrScheme

In the PLT discussion list thread titled “How to handle large data”, Kenichi wanted to load a very large file into DrScheme, 120,000 lines long, and it was hanging. Noel explained that because of debugging and performance instrumentation, DrScheme adds a lot of overhead, and that MzScheme could load the file just fine. Eli explained that DrScheme’s overhead could be made much smaller by making the contents of that file one big piece of quoted data, and that the overhead could be completely eliminated by putting the data in a file and then loading it.
The following code is a generalization of the two approaches that he described there, which were tailored to Japanese postal data.

(define info-list-data
  '(("Alpha" "Bravo" 1)
    ("Delta" "Echo" 2)))
(define-struct info (fname lname budget))
(define (info-data->info entry)
  (make-info (first entry) (second entry) (third entry)))
(define info-list
  (map info-data->info info-list-data))
(define info-list-from-file
  (map info-data->info
       (call-with-input-file "data-overhead-elimination.data" read)))
(display "Total budget: ")
(display (apply + (map (λ (info) (info-budget info)) info-list-from-file)))
(newline)