PetitParser Bon Mots

Frank Shearar wrote “I’ve been working with parsing number literals in Smalltalk recently. I’ve discovered a small collection of tricks not entirely explained in PetitParser’s otherwise excellent documentation, so I thought I’d share my experiences:”

Rolling your own control structures with lambdas

Frank Shearar wrote “Squeak Smalltalk ships with an, ahem, mildly controversial feature: a case statement. Case statements usually evoke “but that’s not OO!” from people, usually with good reason: a complicated case statement only gets less understandable as it evolves, while a State implementation’s complexity remains more or less constant. (You can concentrate on only the bit you…”

Un Petit Haskell

Frank Shearar wrote “It’s time to visit another Smalltalk PEG parser. We’ve seen OMeta2, and now it’s time for a rather different approach to parsing. Lukas Renggli wrote PetitParser, a parser library based on parser combinators.”

The Other Kind of Zipper

Frank Shearar wrote ““A zipper is a[n editable] suspended walk.”[1] Take a map: it takes some traversable structure, executes a function on each element, and returns a new traversable structure with the values obtained by applying the function to the elements of that structure. Define a function that returns a pair (value, partial continuation) where the partial continuation…”

Zipping over Magritte-described Objects

Frank Shearar wrote “Magritte is a metamodel description framework for Smalltalk, that is, a way of describing your domain objects. Having a description of your domain objects allows you to do a bunch of neat things, like automatically building a Seaside form for displaying an object. If you’ve used C#’s ASP.Net MVC framework, you might think of the…”

Unification: pattern matching, but twice as nice!

Frank Shearar wrote “Languages like ML, Newspeak, and Scala support pattern matching: it’s a bit like a case/switch statement, only instead of matching on a series of boolean conditions you switch on the shape of some variable. But Prolog goes twice as far: Prolog uses unification. What’s that, you ask?”

Algebraic Data Types and OMeta2

Frank Shearar wrote “There have been a recent rash of grammar libraries written for Smalltalk. We have at least three Parsing Expression Grammar (PEG) libraries: OMeta2/Squeak, Xtreams and PetitParser. Today we’re going to look at OMeta2.”

Balancing trees

Frank Shearar wrote “Have tree. Will use zipper to mutate. Much rejoicing. Only, when you have a binary search tree, you’d like to have a balanced tree so you get the O(lg n) search rather than a list masquerading as a tree (so all nodes only have left or right children), which would give you O(n) search. What…”

Direct implementation of shift/reset in Smalltalk

Frank Shearar wrote “My work on zippers led me to a very strange thought, which I’ve constructed from Oleg Kiselyov‘s and Chung-Chieh Shan‘s papers: “a zipper is a suspended walk is a delimited continuation”. That was too intriguing to let go, so I started reading. That in turn led me to the “control operators”, things that let us…”

The Anatomy of a Browser

Frank Shearar wrote “I’ve been busy rewriting the guts of Squeak’s Browser. It’s an important tool: it’s the primary way we write code and explore the system. It’s also the tool I must use to edit the Browser. Time to operate on my own brain again!”

Traversing objects functionally

Frank Shearar wrote “Like Tim, I’ve been playing around with zippers recently, only I’ve been working in Smalltalk. In particular, I’m trying to explore how easy it is to work with objects in a fully functional way [1]. With that in mind, I’m working within certain constraints, most important of which is “thou shalt use immutable data structures”.…”

Squeak 4.2 released

Frank Shearar wrote “Squeak 4.2 has finally shipped! It continues the improvements started in 4.0 and 4.1, with the trunk model revitalising the community: a small group of dedicated, frequent committers provide the main thrust of development, supported by a very simple and lightweight way of providing bugfixes, enhancements, and the like. Squeak 4.2 also ships with the Cog VM, Eliot…”