DIVREI TORAH IN UNCLEAN PLACES
Ta'anis 20b: R. Zeira or Rav Ada bar Ahavah said that one of his merits for long life was that he never thought about Torah in filthy Mavo'os (alleyways).
Berachos 24b - Version #1 (Rav Huna citing R. Yochanan): If one was walking in a filthy Mavoy (at the time of Shma), he should put his hand over his mouth and say Shma.
Rav Chisda: Had I heard that even from R. Yochanan himself, I would not follow it!
Version #2: Rabah bar bar Chanah said this in the name of Reish Lakish. Rav Chisda said that he would not follow it even if he heard it from Reish Lakish himself. (end of Version #2)
Question: Rav Huna could not have said this!
Rav Huna: It is forbidden for a Chacham to stand in a filthy place, for he cannot avoid thinking about Torah.
Answer: He may not stand in a filthy place, but he may walk through it while thinking about Torah.
Question: R. Yochanan could not have said this!
R. Yochanan: It is permitted to think about Torah anywhere except for the bathhouse or Beis ha'Kisei (or other filthy places).
Suggestion: Perhaps he forbids one who stands in a filthy place, but not one who walks through.
Objection: R. Avahu was walking behind R. Yochanan and reciting Kri'as Shma. He came to a filthy Mavoy and stopped. Later, he asked where to resume.
R. Yochanan: If you paused long enough to finish Shma, you resume from the beginning. (If not, you resume from where you left off.)
Answer: R. Yochanan answered according to R. Avahu's opinion:
I hold that one who walks through need not stop. Since you hold that one must stop, if you paused long enough to finish, you resume from the beginning.
Support (for Rav Huna - Beraisa #1): If one was walking in a filthy alley, he puts his hand over his mouth and says Shma.
Support (for Rav Chisda - Beraisa #2): If one was walking in a filthy alley, he may not say Shma. If he was in the middle of saying it, he must pause.
Avodah Zarah 44b - Mishnah: A Nochri Min saw R. Gamliel bathing in the bathhouse of Afroditi (an idolatry).
The Min: This is forbidden to you - "Lo Yidbak b'Yadcha Me'umah Min ha'Cherem"!
R. Gamliel: We do not answer (matters of Torah) in a bathhouse.
After he left, he explained that here, Afroditi is not treated like a god, therefore it is permitted.
Question: How could R. Gamliel say in the bathhouse 'We do not answer...'? (This is Divrei Torah!)
Rabah bar bar Chanah: One may think about Torah anywhere except for a Beis ha'Kisei or bathhouse!
Answer (Beraisa): He said this after he left.
Shabbos 150b - R. Yochanan: R. Yehoshua ben Korchah expounds "Mi'Mtzo Cheftzecha v'Daber Davar" - speech (that explicitly discusses Melachah) is forbidden on Shabbos, but thoughts are permitted.
Question (Rav Acha bar Rav Huna): This implies that thoughts are not considered Dibur (speech). But R. Yochanan himself taught that one may think about Torah anywhere except for a bathhouse or bathroom, for this is not "V'Hayah Machanecha Kodesh";
Here also it says "V'Lo Yir'eh Vecha Ervas Davar" (he should likewise expound, speech is forbidden, thoughts are permitted)!
Answer: We expound "Ervas Davar" to forbid reciting Shma facing a naked Nochri.
Rif and Rosh (Berachos 15b and 3:42): A Chacham may not stand in a filthy place, for he cannot avoid Torah. One may think about Torah anywhere except for a bathhouse or Beis ha'Kisei.
Rif and Rosh (Shabbos 19a and 3:12): One may think about Torah anywhere except for a Beis ha'Kisei or bathhouse. Divrei Kedushah are forbidden in any language; secular matters may be said even in Lashon ha'Kodesh.
Rambam (Hilchos Kri'as Shma 3:4): One may not say Divrei Kedushah in a bathhouse or Beis ha'Kisei. Even Hirhur (thinking) about Divrei Kedushah is forbidden there are or in a place of filth, i.e. excrement or urine.
Kesef Mishneh: Since the Gemara does not specify, it seems that Divrei Kedushah are forbidden in a Beis ha'Kisei even if it is empty of people, and even in a bathhouse empty of people, even if it is new.
Me'iri (Shabbos 40b DH Mutar): Anywhere is permitted, i.e. even if one is unsure whether or not the place is clean, except for a Beis ha'Kisei or bathhouse. Those are forbidden even if it they are clean.
Shulchan Aruch (OC 85:2): Even Hirhur about Divrei Torah is forbidden in a Beis ha'Kisei or bathhouse or in a place of filth, i.e. excrement or urine. One may say secular matters in Lashon ha'Kodesh.
R. Yonah (Berachos 8b DH Lo): If one may not say a Berachah or Tefilah, e.g. if his hands or the place are not clean, e.g. a Choleh in a dirty bed, he should think the words in his heart. Even though he is not Yotzei, he receives reward for his intent.
Beis Yosef (DH Lo): All the Poskim forbid even Hirhur in a place of filth. Perhaps R. Yonah does not refer to true filth. Nevertheless, if he cannot clean it he may not say Tefilos out loud.
Magen Avraham (62:2): R. Yonah discusses places such as the middle room of a bathhouse. The Shlah says that R. Yonah means that one should think about his obligation and feel bad that he is unable to bless. The words of R. Yonah connote otherwise.
Magen Avraham (85:2): It is Midas Chasidus not to speak in Lashon ha'Kodesh. One may not speak Divrei Torah facing Ervah, but Hirhur is permitted. We must say that the bathhouse is forbidden because it is a place of excessive filth.
Mishnah Berurah (5,6): Obviously, in the Beis ha'Kisei one may think of the lowliness of man, and that in the end he will be dirt and worms and that it is improper for him to be haughty. It is good to make calculations of his business there, to avoid Hirhur of Torah. On Shabbos one may think about nice buildings or pictures.
Rema (YD 246:26): Even though a Chacham may not stand in a filthy place lest he think about Torah, one may enter a bathhouse amidst learning, even amidst Halachah that was not clearly decided. We are confident that he will be careful not to think inside the bathhouse,
Shach (28): It is forbidden to pray amidst Halachah that was not clearly decided. There, having to cease learning will distract him during Tefilah. Also, since it is also Kodesh, he is prone to think about the learning. The Darchei Moshe says that a bathhouse is different than a filthy Mavoy.