ON the face of it, liberalism is a piece of cake. It’s an excellent political theory and set of moral principles, describing a state of affairs everyone would like to see. There are only four problems with it: people who aren’t liberals, people who are, the theory, and the real world.

A few people, notably James Fitzjames Stephen, spotted this not long after John Stuart Mill published On Liberty in 1859. But even those who worry about contradictions within, or undesired effects that spring from, liberalism usually regard it as what Sellar & Yeatman called a Good Thing. Its central message, after all, is the one advanced nearly 150 years later by those latter-day philosophers Bill S Preston, Esq, and Ted Theodore Logan: “Be excellent to each other. And party on, dudes.”

The trouble is that not everyone agrees on what is excellent, and even if they did, there’s no way of behaving that we can be sure will bring it into being. If you think people have a right to freedom of thought, some of them will think the wrong things; advocate freedom of expression, and some will advocate the wrong things, including things like restricting freedom of expression. That’s the problem with illiberal people.

You can’t have your cake and eat it. I’ll point out, as the Unabomber did, that logically you can have your cake and eat it, indeed, must have your cake to eat it. What you can’t do is eat your cake and then still have it. But anyway, the cake’s the point.

The Supreme Court has ruled on the cake. In case you’ve been on holiday since 2014, this is the case of a bakery in Belfast that refused to make a cake bearing the slogan “Support Gay Marriage” for a gay rights campaigner called Gareth Lee. He sued them for discrimination, won his case, and then won the appeal that Asher’s bakery made against the judgement. On Wednesday, however, the Supreme Court’s five judges unanimously agreed that he shouldn’t have done, and that the bakery was entitled to refuse to make the cake.

Here we have a whole Bake Off tent’s-worth of competing liberal impulses. The purist liberal – libertarian – position would be that any business is entitled to refuse to accommodate anyone on any basis, because they are entitled to think and do what they like, even if the rest of us think they’re wrong. There’s a case for that, but most liberals (indeed, most people) don’t make it, because the beliefs, prejudices and actions of some people lead to others being disadvantaged.

Most of us would think it wrong for a shop to refuse to serve someone because she was a woman, or black, or Catholic, or gay. To say that, and to legislate so that the law says that it is wrong to discriminate on such grounds is, to be sure, a curtailment of the shopkeeper’s liberty: not his freedom to be privately misogynistic, racist, religiously bigoted or homophobic, but his freedom to express those prejudices in a form that harms others. But in most developed countries, precisely because they are historically liberal, we accept that curtailment, because we think it protects wider and more important liberties.

There will always be cases in which the rights of groups clash, and not all of them are as clear-cut as, say, the right of racists to be racist versus the rights of members of ethnic minorities to be treated as equal human beings. I hope we all agree on whose rights matter more there. But – to take a current debate – you may be less certain about the right of transgender people to “self-identify” by declaration versus the right of women to safe spaces which bar anatomically male people.

There’s plenty to be said in that argument (in which both sides are convinced they’re the liberal ones), but the point is that it is a current argument, with legislation dependent on the outcome of the debate. That’s the problem with liberals and the theory of liberalism; claims sometimes clash.

In the case of race, sexual equality and now sexual orientation, the argument has been made and won, at least in theory. You’re free to disapprove of homosexuality, on religious or other grounds, but the law prohibits discriminatory behaviour based on your beliefs.

The problem in the real world is that motivation is not always obvious. It’s wrong to hit someone, obviously. The law says it’s even more wrong if the crime were motivated by hatred. But it won’t always be obvious whether the person was hit because she was black, female, gay or whatever. So it was with Mr Lee’s cake.

The judgement, however, expressly points out that the bakery would have been in the wrong if it had refused to serve Mr Lee because he was gay. The firm would have been in exactly the same moral and legal position as a boarding house that stuck up a sign saying “No blacks or Irish”. The bakery’s owners – who say that same-sex marriage is incompatible with their religious beliefs – would presumably also have lost if, for example, they refused to make wedding cakes for gay couples, while producing them for straight weddings.

Same-sex marriage was unthinkably extreme in most people’s views just a couple of decades ago, and is utterly uncontroversial for most people now. But even that wasn’t the issue. The issue was whether the bakery could refuse, in effect, to publish a political statement. Consequently, no one’s views on same-sex marriages – not even theirs – come into it.

That may be why the human rights activist Peter Tatchell, who has spent his life campaigning on LGBT issues, backed the bakery and welcomed the judgement. Having briefly thought it was a case of discrimination, he revised his opinion and concluded it was about freedom of expression, and legal compulsion.

If the ruling had gone the other way, it would have established the principle that bakers, printers, T-shirt manufacturers and others have to produce any legal message, no matter how controversial, or how much they disagree. That could compel Muslim printers, if they were asked to, to produce cartoons of the Prophet, black ones to run up “Vote BNP” leaflets, or Jewish ones to turn out pamphlets denying the Holocaust. A fairly half-baked sort of liberalism.