Here's a sentence that looks broken in most languages but runs fine in Icon: if line ? find("error") then write(line). There's no == true anywhere, no explicit check against null. The find call either returns a position or it doesn't happen at all — and that absence is the false branch. Nothing coerces to zero. Nothing gets compared against a sentinel. The expression simply fails to produce a value, and failure propagates through the surrounding code the way an exception propagates in other languages, except it's silent, cheap, and built into every single expression in the language.
That's the core idea behind Icon's goal-directed evaluation, and it's one of the cleanest examples in programming history of a language designer refusing to bolt a feature onto a paradigm it didn't belong to.
The Problem Was Text, Not Logic
Ralph Griswold built Icon at the University of Arizona as the successor to SNOBOL4, a string-processing language he'd also designed. SNOBOL4 was built around pattern matching on text — scanning strings, trying alternatives, backtracking when a match attempt didn't pan out. That's a search problem: try this, and if it doesn't work, try that, and if nothing works, give up gracefully. Griswold's insight with Icon was that this search-and-backtrack structure didn't need to be a special case bolted onto string operations. It could be the general evaluation model for the entire language.
So instead of expressions returning true or false, every expression in Icon either succeeds and produces a value, or fails and produces nothing. There's no boolean type cluttering the type system. A comparison like x < y doesn't return a flag you then have to branch on — it returns the value of y (or fails if the comparison doesn't hold), which means you can chain comparisons directly: x < y < z actually checks that y falls between x and z, because each step either passes a value forward or kills the whole expression.
Generators Turn "Try Again" Into a Language Primitive
The part of goal-directed evaluation that still feels startling decades later is that failure isn't terminal — it's a cue to retry with the next alternative. Icon calls these producers "generators": expressions capable of yielding more than one result over time if the surrounding context demands another value. find(s1, s2) doesn't just return the first position where s1 occurs in s2 — it can be resumed to produce the second position, the third, and so on, each time something downstream fails and asks for another attempt.
This is why Icon's control structures look deceptively plain while doing something unusual underneath. A loop like every write(find("e", s)) doesn't need an explicit index variable or a manual while-loop checking for -1. The every keyword just keeps asking find for the next result until find finally fails, at which point the loop ends on its own. The backtracking that most languages hide inside regex engines or constraint solvers is, in Icon, just how ordinary expressions behave by default.
What It Cost to Make Failure This Cheap
The tradeoff is that Icon code reads strangely until you internalize that control flow and value production are the same mechanism. A function call in an if condition isn't being tested for truthiness — it's being tested for whether it managed to exist at all. That collapses a distinction most languages treat as fundamental: the difference between "did this computation succeed" and "what did it return." Icon's answer is that those questions were never actually separate, and keeping them apart just meant writing more error-handling boilerplate to simulate what failure-as-control-flow gives you natively.
It also meant Icon never fit neatly into the functional-versus-imperative categories that dominate how we teach languages. It has assignment and loops like an imperative language, but its evaluation strategy — try, backtrack, try the next alternative — owes more to logic programming's search model than to anything in C or Pascal, its contemporaries.
Modern languages reach for generators, optional types, and short-circuit evaluation to get pieces of what Icon did in one unified mechanism back in the 1970s. None of them went as far as making failure itself a first-class, silent, resumable event threaded through every expression in the language. That's worth sitting with the next time you write a chain of ?. null-checks and wonder why it still feels like you're working around the language instead of with it.