The Nikon D50 is alive and well. It is NOT discontinued.
And no, "G" type lenses WILL work with the D40. The D40 can use AF-S and AF-I type lenses and autofocus those types of lenses....THAT is what is key, the AF-S or AF-I designation. The "G" series simply means that there is no "manual" aperature ring on the lens, that the aperature must be set via the camera. After all, the D40 kit COMES with a "G" series lens.
Referring to
www.dpreview.com:
"Auto Focus only for AF-S or AF-I lenses:
Perhaps the biggest negative on the D40 is that it doesn't have an internal focus drive motor and hence no mechanical focus drive pin, instead it only has CPU contacts which means it can only Auto Focus with AF-S and AF-I lenses (those with built-in focus motors). Indeed our 'standard' lens the Nikkor 50 mm F1.8D (and the F1.4D) are manual focus only on the D40."
And from NikonUSA regarding the D40 lens compatibility:
"Compatible Lenses*1: Nikon F mount with AF coupling and AF contacts Type G or D AF Nikkor: 1) AF-S, AF-I: All functions supported; 2) Other Type G or D AF Nikkor: All functions supported except autofocus; 3) PC Micro-Nikkor 85mm f/2.8D: Can only be used in mode M; all other functions supported except autofocus; 4) Other AF Nikkor*1/AI-P Nikkor: All functions supported except autofocus and 3D Color Matrix Metering II; 5) Non-CPU: Can be used in mode M, but exposure meter does not function; electronic range finder can be used if maximum aperture is f/5.6 or faster; 6) IX Nikkor lenses cannot be used
*1. Excluding lenses for F3AF"