Virginia is virtually alone among the states in blocking those from beyond its borders from using its Freedom of Information Act to get state documents and records.

The question before the Supreme Court on Wednesday was: So what?

The court spent a spirited hour debating whether Virginia had a good reason for making a distinction between its residents and out-of-staters, or whether the state even needed one.

Two men — Mark McBurney of Rhode Island, who wanted to examine records from the state child support enforcement division, and Californian Roger Hurlbert, who operates a business obtaining real estate tax assessments — challenged what their Washington attorney, Deepak Gupta, called Virginia’s “discriminatory access policy.”

Gupta said it violated a provision of the Constitution meant to put residents of the states on equal footing, and also the dormant-commerce clause, which guards against economic protectionism.

But Gupta ran straight into Justice Antonin Scalia, who coincidentally is one of four justices who live in Virginia. Scalia said he remembered the advent of “government in the sunshine” laws that popped up around the country, starting in Florida, during the 1960s.

“It seems to me entirely in accord with that purpose of these laws to say it’s only Virginia citizens who are concerned about the functioning of Virginia government, and ought to be able to get whatever records Virginia agencies have,” Scalia said. “What’s wrong with that reasoning?”

As the argument progressed, Scalia became more colloquial: “They don’t want outlanders mucking around in Virginia government. It’s perfectly okay for good old Virginians to do that, but they don’t want outlanders to do it. Why — why is that unreasonable?”

And as his colleagues pressed Virginia Solicitor General E. Duncan Getchell Jr. to explain why the state had such a law, Scalia became more animated.

“Is it the law that the state of Virginia cannot do anything that’s pointless?” Scalia asked. “Only the federal government can do stuff that’s pointless?”

Some of Scalia’s colleagues joined in. Justice Ruth Bader Ginsburg said perhaps the law was no different from Virginia banning out-of-staters from voting. “They’re not part of Virginia’s political community,” Ginsburg said. “So why isn’t this — if you’re not part of the political community, then you don’t fall under FOIA?”

Gupta said that the state cannot say that “because one purpose of this law is that we want to constitute ourselves as a political community, that we can exclude activities that have a big commercial effect.”

Gupta’s clients are supported by a broad coalition of business interests and media organizations, including The Washington Post. (There is an exception in the law for newspapers that circulate or television and radio stations that broadcast in the state.)

Some justices seemed interested in Gupta’s argument that there is a national interest in the kind of economic information that Hurlbert supplies.

Justice Anthony M. Kennedy seemed unsatisfied with Getchell’s answer that he was “agnostic” on whether the documents and records had commercial value. Getchell said the purpose of the law was “political, not commercial.”

Justice Stephen G. Breyer did not think Getchell had responded to Gupta’s argument that “there is a national interest in the flow of this information. And that means you have to have a better than ‘uh-huh’ kind of rationale.”

And Justice Elena Kagan was of a similar mind. “It seems to me you have a very good case that these statutes were meant for a different purpose,” she said. “But in fact, it seems as though your friends there have a good case that these statutes have been taken over, to a large extent, across the country by economic enterprises doing economic things.”

Getchell said that much of the information the challengers wanted is available to them under Virginia laws other than the FOIA.

The liveliness of the session was underscored when Kagan decided to have fun at her colleagues’ expense. While others talked about the advent of so-called sunshine laws in the 1960s — “They were very much the fad,” Getchell said — the youngest justice said she wouldn’t know.

“I want to put myself on record as not remembering when these statutes were passed,” said Kagan, 52.

The case is McBurney v. Young .