September 06, 2013

Parenthesis can be tricky...

You probably didn't see this coming.

August 18, 2013

The Human Consequences of Dynamic Typing

I agree with Jay McCarthy that static typing is anti-human. I think I can give a slightly more elaborate example of a program that every static type checker must reject, but that is nevertheless correct. Everything below is valid Common Lisp:

(defclass person ()
  ((name :initarg :name
         :accessor person-name)))
(defmethod display ((p person))
  (format t "Person: Name ~S, address ~S."
            (person-name p)
            (person-address p)))

A static type checker must reject this program because there is no address field defined in the class person that person-address presumably refers to. However, below is a run of the program in a Lisp listener that runs to a correct completion without fatal (!) errors:

CL-USER 1 > (defvar *p* (make-instance 'person :name "Pascal"))
*P*
CL-USER 2 > (display *p*)
Error: Undefined function PERSON-ADDRESS called with arguments
(#<PERSON 4020059AB3>).
  1 (continue) Try invoking PERSON-ADDRESS again.
  2 Return some values from the call to PERSON-ADDRESS.
  3 Try invoking something other than PERSON-ADDRESS with the
    same arguments.
  4 Set the symbol-function of PERSON-ADDRESS to another
    function.
  5 (abort) Return to level 0.
  6 Return to top loop level 0.
Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for
other options.
CL-USER 3 : 1 > (defclass person ()
                  ((name    :initarg :name
                            :accessor person-name)
                   (address :initarg :address
                            :accessor person-address)))
#<STANDARD-CLASS PERSON 4130371F6B>
CL-USER 4 : 1 > :c 1
Error: The slot ADDRESS is unbound in the object
#<PERSON 41303DD973> (an instance of class
#<STANDARD-CLASS PERSON 4130371F6B>).
  1 (continue) Try reading slot ADDRESS again.
  2 Specify a value to use this time for slot ADDRESS.
  3 Specify a value to set slot ADDRESS to.
  4 (abort) Return to level 0.
  5 Return to top loop level 0.
Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for
other options.
CL-USER 5 : 1 > :c 3
Enter a form to be evaluated: "Belgium"
Person: Name "Pascal", address "Belgium".
NIL
CL-USER 6 > (display *p*)
Person: Name "Pascal", address "Belgium".
NIL

The "trick" is that the Lisp listener allows for interactive modification of a program while it is running. No static type checker can anticipate what modifications will be performed at runtime.

This is not a toy feature of Common Lisp, but something that many Lisp developers rely on. For example, my own ContextL library crucially relies on the very class redefinition feature I demonstrate above. Joe Marshall provides another account how such features can solve real-world problems.

February 17, 2013

Closer to MOP supports ABCL 1.1.1

The darcs repositories of Closer to MOP now also support ABCL 1.1.1. I plan to make a more official release soon. The Common Lisp implementations currently covered are now as follows: Allegro 9.0, ABCL 1.1.1, CLisp 2.49, Clozure Common Lisp 1.8, CMU CL 20d, ECL 12.12.1, LispWorks 6.0.x and 6.1.x, SBCL 1.1.4, and SCL 1.3.9.

September 25, 2012

Closer to MOP on ABCL and ECL

Just to report on work in progress: I am currently working in my spare time on making sure that Closer to MOP works (again) with ABCL and ECL. ABCL is in relatively good shape, but still needs a couple of bugs fixed here and there. Rudi Schlatte is doing a fantastic job at responding to bug reports. I'm pretty sure the next release will have excellent Closer to MOP support. ECL's recent version came with several changes in its CLOS MOP implementation which broke a lot of things in Closer to MOP, so the current version of Closer to MOP doesn't work with ECL. I'm doing what I can to make sure Closer to MOP is back to speed again with ECL. However, I can only do this in my spare time, and will be busy moving in the next couple of weeks, so some delays are to be expected...

August 09, 2012

Arguments against call/cc

An excellent collection of good arguments against having call/cc in a programming language (such as Scheme), by the ever-inspiring Oleg Kiselyow: An argument against call/cc.

May 02, 2012

Common Lisp, the Untold Story

Nice article by Kent Pitman, mostly about his experiences with the Common Lisp standardization process: Common Lisp, the Untold Story.

100% programmed in Common Lisp, the artificial intelligence applications development language

A short article about an apparently successful digital livescan fingerprinting system.

November 08, 2011

Bertrand Meyer about John McCarthy...

Nice essay about John McCarthy.