Skip to main content
  1. Posts/

“This means something”

Last night in my Computer Language Design class I tuned out the professor after the first 5 minutes. It’s not that the class doesn’t interest me, it’s just that an involved discussion of the taxonomy of languages (presented by a man I can only describe as the stereotypical aging CPA) puts me to sleep. So instead I read ahead in the textbook. Actually I read the end of the textbook, the section on functional and logical languages.

So it suprised me this morning when reading the Python Daily URL to see Bill talking about guards .

Bill points to Erlang as a model for guards and generics. I have to confess complete ignorance regarding erlang. But I like what I saw in Haskell . A brief example, defining the fact (factorial) function:

fact 0 = 1 -- zero step
fact n = n * fact (n-1) -- induction step

Haskell also has cool pattern matching and lazy evaluation. For example, you can create an infinite length list of even, positive integers with the following:

pos_ints = [2,4..]

I’m not sure what the “Pythonic” version of Haskell guards looks like, but the simplicity and elegance really appeals to me. And it seems sorta weird (in a cool way) that less than 12 hours after reading about functional languages, guards and generics, I find others talking about the same thing.