I want to mix Cycles shaders based on self shadow
Turns out this is pretty easy to do. "Easy" as in "you're deprived of doing all the fun math manually" ;)


Add three Value nodes (or a single Combine XYZ node) into which drivers can be added. I prefer the three value node approach in case you want to access individual axes later on.
Add drivers to each of the value nodes by right clicking on each and selecting Add Driver.
In the Graph Editor and switch to Drivers mode in the header (1).



Ensure that both the object using the material and the value nodes are selected, then repeat the following until all the drivers are set up:


Select the next driver in the driver list on the left of the graph editor
Select the driver target, in this case the point lamp (you can press E while hovering over this field, then click on the lamp in the 3D view for a speedier selection workflow)
Set the transform type to X, Y, or Z Location, making sure to pick the right one for each driver
Set the driver type to Sum Values. We don't need any fancy scripted python stuff, and avoiding the Scripted Expression setting will prevent the drivers from being disabled for security reasons.

If you put the drivers on value nodes, connect them to a Combine XYZ node.
Add a Vector Math node set to Normalize and connect the Combine XYZ node. This will ensure the values from the driver are scaled down to the 0..1 range.
Note that only the first input of the normalize node is used, so I've hidden the extraneous sockets with &#9096; CtrlH.
Take the Dot Product of the normalized location and the object's normals (obtained from either a Texture Coordinate or Geometry node) via another Vector Math node.
Adjust the scalar result of the dot product to suit our needs better with some math nodes and a colorramp:




The resulting gradient should update in real time: