Would it be possible, from a legal point of view, to create a software license that would prevent someone from patenting any part of software (source code) released under that license?
I know there are some licenses, like Apache 2.0 and MPL, that void the license for licensees if they try to pursue any patent infringements against the licensor. But it is a bit different, because it still doesn't prevent someone from trying to raise a patent for the software released under that license. But the lack of licenses that would prevent that makes me think that there must be something that makes creating such a license difficult, if not impossible, because I don't believe it's only me who has got such idea in mind.
Edit: I know the software itself can't be patented, only the way the algorithm in that software resolves a specific problem. I use 'software' as a generic term because there is no way of knowing what kind of patent someone can see and can attempt to register based on that software. Say the software may be resolving a specific problem in a new way and the author may not even know about that, yet someone else, maybe knowing the domain better, may see the novelty and try to steal the idea and patent it. Is it possible to prevent that from happening only by wording the license in a specific way?