At an unsuccessful dinner party in an expensive house in Greenwich, London, a man named Miles excuses himself just before dessert, goes upstairs, and locks himself into the spare bedroom. When his hosts, a materialistic couple called Genevieve and Eric, discover him there, he declines to come out. He pushes a note through the crack: “Fine for water but will need food soon. Vegetarian, as you know. Thank you for your patience.” The hosts want to evict him but can’t bring themselves to break down their 18th century door.

The couple, Genevieve and Eric (Gen & Eric, “generic”), try to get Miles to leave by slipping packages of ham under the door. “You have no idea how awful this is for us,” Gen wails. “There is lovely, lovely furniture in there.” Nothing works. Eventually, Miles’s fame spreads. A crowd stations itself permanently outside the back window, acclaiming him as a sort of modern anchorite, a saint walled into his cell. Gen, making the best of a bad situation, starts selling souvenirs.

Postmodern literature, of the Jonathan Safran Foer/“Dog in the Night-Time” variety, is often characterized by gimmicks and tricks. In “There but for the” Ali Smith throws in the whole bag. She packs her narrative with puns and wordplay. (Each section, for instance, begins with one of the four words from the title.) She weaves in obscure knowledge about astronomy, English history, musicals of the 1930s, Dutch winners of the Eurovision Song Contest (“Ding-a-Dong,” 1975). She writes dialogue without quotation marks. Filling her story with facts and fragments, she takes the risk of driving her readers crazy.

Yet the result isn’t madness. Instead, Smith’s new book is sparkling, magical, and full of warmth and heart. If she plays intellectual games, it’s not to disrupt or deconstruct the narrative, but to help her get at emotional truths. She breaks the story into fragments to reflect our fragmented age, but between the pieces she slips in simple, powerful thoughts about decency, kindness, and connection.

Over the course of the novel, Smith shows us the enigmatic Miles through the eyes of four near strangers whose life he changes. (Another postmodernist trick: telling the story from several different points of view.) Anna remembers him as a 17-year-old boy who was kind to her on a school trip. She is now a single woman in her forties who has left her work at a “refugee processing centre” after her boss told her she had “just the right absent presence” for the job. Miles’s situation reminds her of illegal aliens hidden in trucks. But she also thinks “Knock-knock. Who’s there?” then considers it as an existential question. Who is she? What would it mean to be “there”?

The other narrators are Mark, a gay man in his sixties; May, an elderly housewife; and Brooke, Gen and Eric’s neighbor, an extremely precocious and talkative nine-year-old girl. (Yet another postmodern device: a narrator who is mentally peculiar.) At one time or another, Miles has eased their loneliness and shown them how to see things in a new light.

The story takes place in Greenwich and the Greenwich Observatory plays a role, letting the characters think about clocks, distance, boundaries, “the thin lines between here and gone, then and now, here and there.” A local church dedicated to St. Alfege, an 11th-century martyr who was imprisoned by the Vikings and learned wisdom in his cell, lets Smith bring in themes of monasticism, spirituality and historical distance.

Even Smith’s silliest word games have metaphorical overtones, like the knock-knock jokes and the one about the man who invented the door knocker and was awarded the No-bell Prize. The translators can’t have had an easy job. (The Dutch text, by Irving Pardoen and Meindert Burger, is remarkably lively and readable under the circumstances, though not free from the usual sloppy mistakes.) Even the English title, “There but for the,” is a riddle, the first half of a saying: in full it’s the compassionate observation “There but for the grace of God go I.” For Smith, I think it translates to a moral imperative to look outside yourself—and to open your heart.

The connections between all these ideas can feel a little contrived at times, and Smith’s satire of two-earner complacency a bit heavy-handed. She makes up for it with an impressive control of her themes, and especially with a great gift for creating lovable characters with complex human hearts. That’s one difference between this new book and her 2005 novel “The Accidental.” That book was also about a stranger arriving in a household, as seen by the four members of the family who take her in. But those characters were unhappy, secretive people living false lives, while the characters in the new book are appealingly open to the world.

At the end, Miles explains to Brooke, the too-bright nine-year-old, that intelligence is a good thing. “But there’s no point in just having it. You have to know how to use it. […] Instead of being the cleverest, the thing to do is become a cleverist.” In her call for a wise use of all our resources, especially our brains, Smith has written a book that is profound, whimsical, and irresistible.

Trouw, Nov 5, 2011. Ali Smith, “There but for the” (London: Hamish Hamilton, 2011). “Als niet dan zou” (Amsterdam, Mouria, 2011).