Working with DrScheme 372

DrScheme is a delightful environment for working with Scheme. It is has the right balance between power and ease-of-use that makes it perfect for just about anyone. Its goal is to be an excellent vehicle for both working with Scheme and facilitating learning via its teach-pack facilities. While DrScheme works pretty really well “out of the box”, you ought to dig deeper into the documentation and configuration options. Over the past year or so I’ve used DrScheme exclusively for editing Scheme and found that there are a few key-bindings, settings, tools, and ideas that were very helpful to me.
Continue reading “Working with DrScheme 372”

Live Coding with Fluxus

Fluxus is a live coding system built on PLT Scheme.

Fluxus reads live audio or OSC network messages which can be used as a source of animation data for realtime performances or installations. Keyboard or mouse input can also be read for games development, and a physics engine is included for realtime simulations of rigid body dynamics.

Fluxus is a very cool system and the maintainer Dave is a very nice guy. Be sure to check it out!
Addendum: 8/14/8
Dave posted some links to videos of fluxus and the no copy paste jam.
(via PLT)

Mr Ed Designer: Generating User Interfaces with PLT Scheme

PLT Scheme’s user interface library is called Mr Ed. It is used to provide DrScheme to thousands of computers running Windows, Mac OS, and UNIX. It “just works”, and does so well; it is a fine graphics toolkit. MrEd Designer aims to make Mr Ed even easier to use!
Addendum: 7/14/8:
Peter Ivanyi now maintains this application.
Addendum: 09/10/08:
MrEd Designer 2.1.2 is released; it now supports tab-panels.
Addendum: 09/20/08
In MrEd Designer 2.1.3:

  • tooltips are added for the main buttons
  • the no-border style for the tab-panels is fixed.

Distributed Programming in Scheme

Here are two places to start with distributed programming in Scheme:
Termite
Dimitris Vyzovitis’s patch for revision 8983 (of trunk) in PLT Scheme
Addendum 03/21/08

  • Dimitris’ patch for additional mailbox functionality.

Addendum 04/26/08

Addendum 06/24/08
I’m pretty sure this patch has made it into the main source branch.

DrScheme: Insert Lambda Template Keybinding

DrScheme provides a very versatile keybinding system. Out of the box you get bindings that make it very easy to navigate and even refactor your code. One keybinding, insert-lambda-template, works by surrounding the selected code with a lambda function. By default, insert-lambda-template uses the lowercase lambda symbol λ rather than the word lambda. As DrScheme encodes its files in utf-8 it has got no problems with this (in fact DrScheme has shortcuts for inserting most other Greek characters), but if you use other tools to edit or process your source code you may find that they (quite disappointingly) choke on it. For that reason, I wanted to modify the keybinding so that it would use the world lambda rather than the symbol. There are two ways to go about doing this.
The first involves modifying the source code of DrScheme itself. This sounds harder than it is as it doesn’t even involve downloading the source code. When you install DrScheme, it includes a number of source files used to customize itself. If you wanted, you could look up this keybinding, change it, and re-run the setup program. I don’t like this approach, though, since it forces the user to re-build part of the program. That leaves us with the second alternative, a custom keybinding.
A custom keybinding is easy to implement and add. To write it, I copied the definition of insert-lambda-template and changed the lambda symbol to the word lambda. Next, I went through DrScheme’s Edit->Keybindings menu to select Add User-defined Keybinding. That is all it takes.
My keybinding file can be downloaded here.

DrSync: Automatically synchronize file changes in DrScheme v370 and above

DrSync is a plugin that saves your files on frame deactivation and reverts them on frame activation. This tool is of particular interest to folks who run external programs like version control or build related tools on files which they are editing inside of DrScheme.
Continue reading “DrSync: Automatically synchronize file changes in DrScheme v370 and above”

Using Scheme's Eval in Sandbox

One of the most tantalizing features that folks hear about Scheme is the eval function. While in reality, when it comes to meta-programming most modern Scheme distributions have evolved other mechanisms to do so, eval is still a big draw. The biggest shock most folks have when it comes to Scheme, though, is that you can only evaluate expressions in the top level environment. If eval holds your interest long enough, for perhaps any number of different different reasons, you will eventually reach the point where you want to do use it to evaluate code that you didn’t write (my inspiration came in the form of the Dolphin Smalltalk tutorial task where you write network chat clients that can send code to each other for execution). Whatever *your* inspiration was, though, you will also reach the point where you realize that you don’t necessarily want arbitrary code to be executed in the environment in which you are running your program; you don’t want folks sending (exit) for example, that can be pretty irritating. One way to work around this issue to to evaluate your code in a sandbox.
Here are three ways to do it with PLT Scheme: DynamicEvalCustomNamespace, DynamicUntrustedEval, and Sandboxed Evaluation.
Addendum 04/22/08:
Here is a link directly to the Schematics PLT package which provides “a library of useful procedures on namespaces”.

Scheme Lisp on the OLPC XO

Out of the box, the OLPC XO comes loaded to the gills with Python, but sadly, no Lisp!
To remedy that situation I enlisted the help of the kind folks on the PLT discussion list to help me write a script to build the PLT DrScheme (Lisp) development environment for the XO.
This script is responsible for preparing the PLT application suite for the OLPC XO laptop computer. The script creates a typical binary, *not* a Sugar application (that is going to take a little more work!). You can download the application itself here, along with the md5 checksum, and the build log. A Flickr photoset is available here.
If you do try it out, please be sure to read the usage notes below, and let me know if anything needs to be added to them. All of the documentation is pre-installed, so once you’ve downloaded it, extracted the archive, and executed ‘drscheme’ (or ‘mzscheme’ if you want command line Lisp) in the bin dir, you should be ready to roll.
Thanks to all of the hard work by both the PLT and OLPC folks, lives will be changed.
Usage Notes

  • The apps run quickly. The slowest part is, of course, the disk I/O.
  • Slideshow works very well; it looks great and runs fast, turning the XO into a wonderful little “personal” presentation machine.
  • Out of the box, there is one setting in Edit->Preferences->Editing->General that is left unchecked: Open files in separate tabs (not separate windows). Left unchecked, opening a file will occur in a new window, and creating a new file will occur in the same editor. Check this feature. It will prevent multiple instances of DrScheme, conserving resources, and perhaps equally as important, it will make DrScheme more fun to use. “Reuse existing frames when opening new files” should not be checked!
  • Help desk works wonderfully with one caveat. When you are running Sugar and you switch between applications, more than one “unknown app circle” will show up in the “Donut”, each one corresponding to a DrScheme window. When you try to return to the help desk, you will find that you are always returned to the DrScheme IDE window. In order to get back to the help desk window, return to the DrScheme IDE window and then use alt+tab to switch to the help desk.
  • In this build of DrScheme, the IDE will resize to accomodate long file names. Although the XO screen has a very high resolution, it is very small, and large fonts are used to accomodate this. As a result, when file names longer than 16 characters are loaded, the IDE will expand off of the right side of the screen. This behavior will not be present in the newer version of DrScheme.
  • The Preferences window buttons “Revert to Defaults”, and “Cancel”, and “Ok” are not visible, appearing just below the bottom bound of the screen. The mouse cursor *can* click these, and in fact when you do click them, you can see the buttons are depressed. “Revert” is on the far left, and then “Cancel”, and finally “Ok” is on the far right, appearing in that order. This is order is different than how it appears on Windows (Revert, Ok, Cancel)!

Addendum 03/22/08:

  • Updated the build script (now tag 004) comments with note about what settings to check in DrScheme, updated the usage notes to reflect this fact
  • Someone asked “By the way, is there a reason that just typing yum install plt-scheme wouldn’t work?”. That is a good question. PLT builds against OpenGL. The XO does not have hardware acceleration. Consequently there are two ways to run PLT on the XO: install Mesa for software-based OpenGL emulation or build PLT without OpenGL support. I chose the latter, without testing the former.
  • In case you are interested in building PLT for the XO using Microsoft Virtual PC, I’ve added my setup notes.

Addendum 05/29/08:
Made a big correction in the order of the preference buttons, also updated the reference to the script which reflects the change.