Emacs Streams

One of the nicest things in Scheme, I think, is the notion of streams. These are basically lazy, infinite lists. The idea is that you want a list of (possibly computationally complex) objects of indeterminate length. You could calculate the list beforehand making more entries than you think you'll need but that's wasteful and you may not have a good handle on how many you'll need.

Streams are very easy to implement and even though the notion never seemed to gain traction in Common Lisp, they are easy to implement there too. Now Nicolas Petton has implemented them for Emacs Lisp too. His stream.el, which is available on Elpa, requires the seq.el library and therefore requires Emacs 25 or later.

It's not obvious what a good use case would be in the Emacs environment but I'm sure there are some. I just like the idea that they're there for me when I find I need them. It might not seem like there would be many opportunities to make use of streams no matter the language but as SICP shows, they are very natural solutions to many problems once you internalize the idea.

Streams for Emacs is another reason I can't wait for Emacs 25.

UPDATE: wouldn't → would

This entry was posted in General and tagged , . Bookmark the permalink.
  • Phil

    Two books I am (rather leisurely) reading at present are SICP and Learn You A Haskell For Great Good. Haskell is lazy to the core, and it's quite an eye-opener to see how things can work when that's just How Things Are in the language.