It's opt-in, otherwise most packages would break.
To enable it per-file use a file-local variable:
;;; -*- lexical-binding: t -*-To enable it per-file use a file-local variable:
;;; -*- lexical-binding: t -*-Or as Perl did it (18 years ago) with a new keyword, so that you can use both dynamic and lexical variables in the same file? Best of both worlds.