"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Showing posts with label lisp. Show all posts
Showing posts with label lisp. Show all posts

Monday, December 29, 2008

Lispful

(1984 Edition: Blogger Destroys Ignorance)

Before leaving on a short holiday adventure following the Northwest Snowpocalypse of 2008, I'd set out to email my blog a short love note to Lisp. After a few helpful comments, blogger destroying same, and Twitter destroying my patience for revising blog posts, I'll try rewriting with previous comments in mind...

Something I really like about Lisp and Smalltalk is the very small number of rules and the very large bang for the buck. Ioke and io fall into that same realm:

Although nothing beats Lisp for me. Consider doubling the fraction 3/2.

In ioke the following expression evaluates to the integer 3:

3/2 + 3/2

Although Smalltalk has fractions (and if it didn't you could add them), the same expression evaluates to the fraction 9/4. Why? Because Smalltalk evaluates binary messages from left to right. There are no "mathematical operators", no "operator precedence", and no syntax for literal fractions. The Smalltalk equivalent to the ioke expression above is:

(3/2) + (3/2)

Or less generally:

3/2 * 2

Smalltalk's fewer rules than the common Algol derivatives are a good thing. As Nat Pryce commented earlier, the mathematical operator precedence rules we learn in grade school are far from universal across all of mathematics anyway. Why cling to them in programming languages?

Now we get to Lisp:

(+ 3/2 3/2)

Fractions can be expressed truly as literal numbers. This evaluates to 3 and there's never any question about "operator precedence". The fewest rules of all: function application is function application. Absolutely uniform. Absolutely lovely.

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.