This state's top appeals court today ruled the Rhode Island death penalty law unconstitutional on grounds that it does not allow judicial discretion in sentencing.

The law, enacted in 1973, provides for mandatory death by gas chamber for persons who commit first-degree murder while serving sentences in the state prison system.

The decision affects the fate of four men now on death row in the state's Adult Correctional Institutions in nearby Cranston. There have been no executions under the 1973 law, and no executions in the state since 1845, when John Gordon was hanged for the murder of a prominent socialite.

The Rhode Island Supreme Court's ruling came in a 4-to-0 vote, with one judge not participating because his former law firm represented one of the two convicted murderers bringing the appeal.

In a decision written by Justice Thomas F. Kelleher, the court noted that the Rhode Island law violated a principle set down by the U.S. Supreme Court in several death sentence cases in recent years.

According to that principle, a death penalty law must permit a trial judge to consider mitigating circumstances including the defendant's character and record.

Because the Rhode Island law does not meet that test, it violates the constitutional prohibition against cruel and unusual punishments, the decision said.

The appeal was brought on behalf of Robert Cline and William H. Anthony. Cline was convicted of shooting a Providence fish peddler to death in a robbery committed after he escaped from the state prison in 1974. Anthony was convicted of first-degree murder in the 1975 stabbing of another prison inmate.

While their lawyers were contesting the constitutionality of the death penalty law, Cline and Anthony last fall wrote a letter to a Superior Court judge asking him to authorize their prompt execution. The prisoners complained that conditions in the prison were unsanitary, inhumane and unconstitutional and that "no type of punishment whatsoever, death included, could be so indecent, intolerable and unfair."

The judge, Anthony A. Giannini, declined to act on the letter on grounds that the case was already on appeal, and he said he considered the letter to be a publicity stunt.