So if you recall this issue that got decided at the Supreme Court of the American Empire, where the prohibition was discrimination on the basis of “sex”. The conflict that surfaced was that the historical and current usage of “sex” clearly excluded gender and sexual orientation, hence these would be admissible for discrimination. However, if you used the reasoning that a man and woman would be treated differently for dressing like the opposite gender, then you would conclude it was discrimination of the basis of sex.
The immediate issue was that the normal legal reasoning, to show the differing treatment of the two populations, was self-referential. Gender identity and sexual orientation have a default association with sex, and the understood meaning of calling out sex and not sexual orientation, directly contradicts that default association. Hence the intent behind choosing only the word sex was to sever that association, but choosing this means of interpretation also has to sever the use of differing treatment between subpopulations, which is essential for proving a case under the general anti-discrimination framework. Hence, without that additional clarification, and showing the places where the differing-treatment method could be used, ambiguities arose in the general application of the law (which is not the same as the issue that was decided, the historical context and literal language supported discrimination by default-deviant gender and sexual orientation).
Although important of itself, this situation is a specific instance of a larger problem: that calling out one decision criterion, without providing a decision rule, or having some other context to resolve what is legal and what is not, tends to cause these types of issues. Consider that you ban housing availability (redlining) decisions on the basis of skin color. Then, if skin color is closely associated with wealth or other proxy, you simply apply the wealth test, and you are able to achieve something close to the similar result, with regards to the test of differing subpopulation treatment.
The largest scope of the issue is that there are a large number of differences in individual behavior, relative to the number of important decisions that get made, and the typical size of organizations. For example, even in a large territory like the American Empire, the vast majority of businesses employ 1000 people or less. If you then consider that there are 100 different dimensions that can be used to sort the subpopulations, you can understand how easy it is to construct a policy that, for the hiring population you accept, works around the inability to use 1 of the 100 dimensions, or even 20 of the 100 dimensions. Add in criteria such as “likability”, “team player”, and aesthetic appeal, and you get even more wiggle room.
Hence from a practical perspective, it is not possible to achieve the desired ban, with just the limited legal language of prohibiting individual characteristics. You must describe the entire decision rule set (not necessarily the implementation in humans or IT automation), and provide the documentation necessary to verify that these decision rules actually were followed. The end result of this decision rule set should be the divided subpopulations and the corresponding treatment. Of course, you would want to follow up with sting operations and other usual enforcement techniques to ensure that the documented system is the real system.