For a man like Arctor (whom we see at one point in the past speeding toward a middle age that's been planned out decades in advance via mortgages, IRAs, and the looming threat of college tuition) the escape of Substance D is obvious. He craves immediate, visceral feedback. Rather than letting minutes, days and years wash over him, he wants to live painfully, sublimely in each moment for the rest of his life. Tough to blame him. It's really, really hard to feel alive most of the time if you're not actively courting death.
A Scanner Darkly's bleak futurism -- complete with suits that scramble a person's appearance and voice -- is an elaborate setup to allow for a meditation on conflict, alienation, and how life seems more interesting when we're killing ourselves. These are points that have been explored before, but rarely a) from a futuristic context and b) with an urgency that feels like typing one's way out of a catastrophic trip.
The repeated acts of denial and indulgence (that is, indulging in whatever suits while denying any sort of dependence), though, create a lot of cognitive dissonance. The part of the self that lusts after that next push grates against the part that has a harder and harder time rationalizing the experiment. This manifests in Arctor as a split between the right and left hemisphere of the brain. As a narc assigned to spy on himself, he's also split his life in half. It's one of the most tangled psychological webs imaginable, and it all, obviously, breaks down.
When it does, Arctor is sent to a detox facility. We expect to leave him there hunched over the admitting room puking his guts out, wishing him the best as the screen fades to black. That's how it usually works. But just as Arctor is settling in for a long winter's withdrawal, a new deus ex machina character explains that Arctor's addiction - as aimless, debilitating and self-estranging as it may have seemed - was all part of a greater plan.
The question of authorship is in play whenever a novel is adapted for the screen, and we're unsure whose vision has won out, Linklater's or Dick's, until just that final moment. The proof that this film about junkies was actually written by one lies in Dick's inevitable reflex action toward messianism. If Arctor were just left to dry out and clean up, then this catastrophic struggle that claimed so many of Dick's friends would have been mere decadence. Dick needed to believe, instead, that it was a process of self-sacrifice and transcendence. That last-second switch does more to speak to Dick's mindset than the previous hour and a half of psychedelic exposition. In leaving the scene intact, Linklater has done the author and the audience a great service.