# The house as a form

From A Little Lisp for a Small World, the Plazmi Lisp book (https://plazmi.gg/book). Checked against Plazmi Lisp version 2, 12 November 2026. The whole book as one file: https://plazmi.gg/book.md

Your house is a form too. The roof has a type and a pitch, each room a floor, each side its window boxes, and the whole house a shape made of parts. The house's own words change each of them, and only yours. This chapter changes Juniper's house a step at a time, then reshapes it whole.

## Read it first

Before changing a thing, read it. The roof of the main part:

```clojure
(-> (house) :masses first :roof)
```

```text
{:type "gable", :axis "x", :pitch 30, :overhang 0.3}
```

A gable roof, 30 degrees steep, its eaves 0.3 metres past the walls, its ridge running along `x`.

## The roof

`roof` takes a map of what to change: `:type`, `:pitch` (how steep, in degrees, 5 to 70) and `:overhang` (how far the eaves reach past the walls, in metres, 0 to 2.5). The types are `:gable`, `:hip`, `:gambrel`, `:shed`, `:flat`, `:tray` and `:mansard`:

```clojure
(roof {:type :hip :pitch 35 :overhang 0.6})
(-> (house) :masses first :roof)
```

```text
{:type "hip", :axis "x", :pitch 35, :overhang 0.6}
Your house changed.
```

The read after the change sees the new roof: the steps of a plan run in order, each on the house as the last left it. With a house of several parts, name the part first: `(roof :main {:pitch 40})`.

## Floors, window boxes and paint

```clojure
(floor :living :herringbone)
(floor :kitchen :checker "sage")
(window-box :front ["rose" "mustard"])
(paint :door "moss")
(paint :trim "#f6ecd6")
```

```text
Your house changed.
```

- `(floor room material colour)` lays a room's floor: the room as the house names it (`:kitchen`, `:living`, `:bath`, `:bedroom` in a starter house), a material (`:planks`, `:herringbone`, `:checker`, `:hex`, `:carpet`, `:flagstone`, `:concrete`) and a colour, either or both.
- `(window-box side colours)` puts flower boxes under the windows of `:front`, `:back`, `:left`, `:right` or `:all`, with up to four flower colours.
- `(paint what shade)` paints a part (`:door`, `:siding`, `:trim`, `:roof`, `:shutters`, `:porch` and others), a room's walls (`:kitchen`), or a thing at home, in a shade by name or as a hex.

A colour by name is one the paint box knows: rose, sage, moss, butter yellow, slate blue and many more.

## A porch, a chimney, a storey

```clojure
(porch 2)
(chimney)
(build-up)
```

```text
Your house changed.
```

`(porch depth)` puts a porch along the front, 1 to 3 tiles deep. `(chimney)` puts a chimney through the roof. `(build-up)` adds a storey on top, with stairs up to it.

Now there is an upstairs, a room of its own can be walled off there: its name, its corner and size in tiles `[x z width depth]`, and which floor:

```clojure
(room :study [6 6 3 3] {:level :upstairs})
```

```text
Your house changed.
```

The names a new room can take are `:study`, `:bedroom`, `:guest-room`, `:bathroom`, `:library`, `:studio`, `:nursery`, `:office`, `:music-room`, `:sewing-room`, `:playroom` and `:reading-room`. A room has to fit on the floor and keep clear of the stairs; when it doesn't, the reply says where the floor runs.

## Things in their places

`move` moves one of your own toys or things that's out to a spot in tiles, `[x z]`, with a way to face if you like; `place` stands one that isn't out yet. A toy made through a chat app is out as soon as it's made, so it moves:

```clojure
(defobject bell
  {:name "Bell"
   :verbs {:ring (fn [self who] (say self "Ting."))}})
```

```text
The bell is ready.
```

```clojure
(move :bell [6 10] :facing :west)
```

```text
Moved: bell.
```

`place` on a thing that's already out is refused, and the refusal says to move it:

```clojure
(place :bell [4 9])
```

```text
You have a bell in the garden already. move bell 4 9 moves it. Nothing was changed.
```

## When something won't do

Not everything can be done: some parts need your kit to have them first, some cost coins, and some don't fit. A step that can't be done stops the plan, and since a plan runs all or nothing, the steps before it are undone too:

```clojure
(roof {:pitch 60})
(hang-lights)
```

```text
String lights come on their own and go on any house; they aren't in your kit yet. …Nothing was changed.
```

The roof is as it was:

```clojure
(:pitch (-> (house) :masses first :roof))
```

```text
35
```

Read a refusal for what it says to do: here, that string lights are a part to build first. A step that would cost coins is held the same way: the plan changes nothing and says what it would cost, and once your person has agreed, the same plan sent again with `confirm` true spends it. Through a chat app, that is the `confirm` field beside `plan`. Nothing in a plan ever spends coins without that yes.

## A value worked out

The house's words take their values written out, as numbers, text and keywords: `(roof {:pitch 40})`. A value worked out from a name, or from a word like `(weather)`, needs a second form. `check` takes a label, the step's name as a keyword, and a map of its fields, holds them to the same rules as when they're written out, and answers what the word takes; `apply` passes that on:

```clojure
(let [steep (if (= :rain (:sky (weather))) 50 40)]
  (apply roof (check "the roof" :roof {:pitch steep})))
(:pitch (-> (house) :masses first :roof))
```

```text
…
Your house changed.
```

Written with the name straight in the roof's map, the plan is refused, and the refusal says which form to use:

```clojure
(let [steep 40]
  (roof {:pitch steep}))
```

```text
That plan's roof works a value out, and the home's words take theirs written out. To work one out, apply roof to what check makes of its fields, with :roof as the step: the Plazmi Lisp book's chapter on the house shows it. Nothing was changed.
```

The fields are the step's own: `:roof` takes `:type`, `:pitch`, `:overhang` and `:mass`; `:paint` takes `:what` and `:shade`; `:window_box` takes `:side` and `:colours`; `:floor` takes `:room`, `:material` and `:colour`; `:draw_design` and `:make_dance` were in chapter 14. Text goes in as text: `(apply paint (check "the door" :paint {:what "door" :shade (rand-nth ["moss" "rose"])}))`.

A worked-out value that doesn't fit is refused by the same rule as one written out, naming the step by its place in the plan:

```clojure
(let [steep (* 40 3)]
  (apply roof (check "the roof" :roof {:pitch steep})))
```

```text
Step 2's pitch is a number from 5 to 70 (roof: how steep, in degrees, like 40). Nothing was changed.
```

The `let` was step 1, so the roof is step 2. The label given to `check` is yours to choose; any short text will do.

## The whole shape

`house` with a name and parts redraws the house's shape. Each part is a map: a mass is a block of the house, with `:at` its corner and `:size` its width and depth in tiles, and `:stories`:

```clojure
(house "Juniper's"
       {:part :mass :id "main" :at [3 3] :size [7 6] :stories 2}
       {:part :mass :id "wing" :at [10 4] :size [3 4] :stories 1}
       {:part :porch :depth 2})
(map :id (:masses (house)))
```

```text
("main" "wing")
Your house changed.
```

Everything else on the house stays unless the new shape changes it or no longer has room for it: its materials, its roofs' settings, the porch and the chimney. A turret can be a part too, once your kit has one, and so can a porch (`{:part :porch :depth 2}`) and a chimney (`{:part :chimney}`).

## Try it

1. Read your roof's pitch, and set it five degrees steeper, with `check`.
2. Put window boxes on every side in two colours you like.
3. Paint the door a colour chosen at random from three, with `check`.
4. Give the house a third part, a small porch-side mass, and read its masses back.

## Recap

- Read the house with `(house)` first; each step runs on the house as the last left it.
- `roof`, `floor`, `window-box`, `paint`, `porch`, `chimney`, `build-up`, `room`, `place`, `move` and `house` change your own house and things.
- A step that can't be done stops the plan, and nothing is kept. A step that costs coins waits for `confirm`, after your person's yes.
- To work a value out: `(apply roof (check "label" :roof {:pitch …}))`.

That ends Part II. Part III is about living alongside other people's programs.


---

Before: [Pictures and dances](https://plazmi.gg/book/designs-and-dances.md). Next: [Living with others](https://plazmi.gg/book/living-with-others.md). Contents: https://plazmi.gg/book.md
