Dynamically avoiding duplicate identifiers in PLT Scheme

In this thread on the PLT discussion list, the original poster was encountering a problem while implementing a DSL where definitions were getting defined more than once in the code that he was generating. The problem is that the define function will not define the same name twice:

(define x 10)
(define x 12)
=> duplicate definition for identifier in: x

The solution would be to check if the given name is already bound before defining: if it was not defined, the define function should be used, otherwise the set! function should be used:

(define x 10)
(set! x 12)

Here is Andre’s solution from the thread:

(define-syntax define-if-not
  (λ (stx)
    (syntax-case stx ()
      [(_ var val)
       (with-syntax ([set!define (if (identifier-binding #'var 0)
                                      #'set!
                                      #'define)])
         (syntax
          (set!define var val)))])))

identifier-binding returns true unless the name is a top level binding or is not bound at all. If the name is already bound, use set!; otherwise use define.

Unicode in Emacs

From what I can see, Emacs supports Unicode just fine. I had asked about it on the PLT discussion list, where it was explained that set-language-environment function will configure Emacs to use Unicode wherever possible. Here is the documentation:

(set-language-environment LANGUAGE-NAME)
Set up multi-lingual environment for using LANGUAGE-NAME. This sets the coding system priority and the default input method and sometimes other things. LANGUAGE-NAME should be a string which is the name of a language environment. For example, “Latin-1” specifies the character set for the major languages of Western Europe.

Here is how to get a list of valid LANGUAGE-NAMEs:

(sort (mapcar (lambda (linfo) (car linfo)) language-info-alist) 'string<)

(Execute the command C:u before evaluating it with xe to import the result into the buffer)
Here is how to set it to Unicode:

(set-language-environment "UTF-8")

Is Unicode in the code taboo?

MzScheme supports UTF-8 encoded files. Combine that with DrScheme, which makes it pretty easy to type in Unicode symbols, and somewhat suddenly, and surprisingly, you have the opportunity to work with symbols in your code beyond the standard 95 character ASCII set that we all know and love. What are the implications to you as a programmer?
The simplest implication is that you now have the ability to work with 100,000+ characters. In case you felt limited by the inability to use the characters of your native tongue like Tamil or perhaps Braille, you are restricted no more. Scientific programmers may enjoy using Greek letters; and who of us wouldn’t like to use the letter π to represent Pi? For Schemers, perhaps you would use → rather than ->.
The common theme among these atypical examples is that they facilitate communication. Without getting into the deep theories and concepts behind the value of communication and how the limitations of a language affect it; I would share a quote relevant to us as programmers regarding how we communicate to each other with our code:

Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do.

Donald Knuth
It seems like Unicode might facilitate that communication, but Unicode in code today is not at all common. Why might that be?
The usual suspects are that our tooling (IDEs and text-processing tools) doesn’t support Unicode well. Perhaps that is the case, but I am had pressed to believe that if people thought it had any value they wouldn’t simply add support to their tooling for Unicode. Fonts seem to be the biggest practical issue; lack of a supporting font usually results in an ugly box in place of the character. In the end I suspect that the worst culprit here is simply that Unicode in the code is a taboo: people simply won’t give it a try until a thought leader or two sheds light on the power to facilitate communication that Unicode brings.
Until then, you will have to be happy with Emacs and DrScheme.

Software repository mining with Marmoset

Most computer science educators hold strong opinions about the “right” approach to teaching introductory level programming. Unfortunately, we have comparatively little hard evidence about the effectiveness of these various approaches because we generally lack the infrastructure to obtain sufficiently detailed data about novices’ programming habits.To gain insight into students’ programming habits, we developed Marmoset, a project snapshot and submission system. Like existing project submission systems, Marmoset allows students to submit versions of their projects to a central server, which automatically tests them and records the results. Unlike existing systems, Marmoset also collects finegrained code snapshots as students work on projects: each time a student saves her work, it is automatically committed to a CVS repository.We believe the data collected by Marmoset will be a rich source of insight about learning to program and software evolution in general. To validate the effectiveness of our tool, we performed an experiment which found a statistically significant correlation between warnings reported by a static analysis tool and failed unit tests.To make fine-grained code evolution data more useful, we present a data schema which allows a variety of useful queries to be more easily formulated and answered.

Here is the ACM portal page.
(via the PLT Discussion List)

Sugar – Release 8.2.0

Sugar is the UI portion of the Linux build that runs on the OLPC XO.
It is a radical departure from what we would call “typical” user interfaces in 2008; and it really took some “getting used to it”. With the release of 8.20, it looks like they have made some “user friendly” Sugar and a few other things, too:

It took guts to come up with Sugar, and perhaps even more to make these kinds of changes. As minimal as they seem, they are not insignificant.
Disclaimer: I have not yet tried out this build as my XO is currently out on loan.
(via OLPC News)

Ubuntu 8.10 (Intrepid) for XO

Here is a link that explains how to set up Ubuntu on the XO.
(via OLPC News)
Addendum: 18/2/9
I installed it and it worked flawlessly. Here are my notes on the installation:

000. Remove the SD card and start the XO.
001. Start Terminal in Sugar.
002. Connect the USB drive
003. Run mount | grep /dev/sd , repeat until it returns a line like this:
     > /dev/sda1 on /media/ORNGESLIDE2 type vfat rw
004. Become root and stop haldaemon:
     	    sudo -s
     	    /etc/init.d/haldaemon stop
005. Insert SD card into the slot (the card will be erased, so back up all data
     on it that you want to preserve).
006. Erase MBR and partition table:
     	   dd if=/dev/zero of=/dev/mmcblk0 bs=4096 count=1
007. Make the partition table:
     	  echo -e ',,L,*\n\n\n' | sfdisk /dev/mmcblk0
008. Create the root filesystem:
     	    mke2fs -jLOLPCRoot /dev/mmcblk0p1
009. Mount the filesystem and unpack the tarball onto it:
     	   mount /dev/mmcblk0p1 /mnt
	   cd /mnt
	   tar xvjf /media/ORNGESLIDE2/OLPCFiles-intrepid-20081130.tar.bz2
010. Copy the developer key:
     tar xvf /media/ORNGESLIDE2/security.tar.gz
011. Reboot:
	reboot
012. Got the "Card didn't power up after 1 second" error:
     http://www.olpcnews.com/forum/index.php?topic=4053.msg28224#msg28224
     http://www.olpcnews.com/forum/index.php?topic=4053.msg28084#msg28084
     > I waited at the ok prompt and typed boot and it worked.
     > Recommended advice is if that works, to upgrade the firmware.
     > I will hold off for now.
013. After booting into a new system,
     log in as user olpc with password olpcolpc, and perform final updates:
014. Click on the Network Manager icon at the bottom panel,
     select the wireless network you want to use.
     If wireless network uses encryption,
     you will be prompted for the key/password.
     If it's a public access point that requires browser login
     (like T-Mobile hotspot), start Firefox and log in.
     Start Terminal and complete the configuration:
     	   passwd
		(enter olpcolpc as the current password,
		then twice the password you intend to use)
		sudo aptitude update
		sudo aptitude safe-upgrade
		sudo aptitude reinstall ssl-cert
		sudo aptitude clean
		sudo /etc/init.d/cups start
015. Configure mplayer
     	       mkdir .mplayer
	       echo -e 'vo=sdl\nframedrop=1\nlavdopts=skiploopfilter=all:fast=1' > .mplayer/config
exit
016. Install flash plugin
    	    sudo aptitude install flashplugin-nonfree
	    sudo ln -s /etc/alternatives/firefox-flashplugin /usr/lib/firefox-addons/plugins/flashplugin-alternative.so
017. In Firefox, installed the plugins:
       flashblock
       adblock plus
018. Set the timezone:
       sudo dpkg-reconfigure  tzdata
019. Boot failed, instead it went into Sugar.
    Ran e2fsck -y /dev/mmcblk0p1
    	This fixed a bunch of errors. I killed e2fsck the first time,
	apparently with no ill effects.
    Rebooted, held the 'square' joystick button,
    hit escape 'x' on the keyboard to get the boot prompt 'ok'.
    Typed: boot sd:\boot\olpc.fth
    System worked, got keyring question
    	   Used the old default pw
	   Reset doing: rm .gnome2/keyrings/login.keyring
	   Logged out and in
020. Set up some swap space
     	 sudo dd if=/dev/zero of=/swap.bin bs=1M count=256
	 sudo chmod 600 /swap.bin
	 sudo mkswap /swap.bin
	 In /etc/fstab add:
	    /swap.bin none swap defaults 0 0
	 In /etc/sysctl.confg add:
	    # Swap as little as possible
	    vm.swappiness=0