Lean4
def whatsNew (old new : Environment) : CoreM MessageData := do
let mut diffs := #[]
for (c, i) in new.constants.map₂.toList do
unless old.constants.map₂.contains c do
diffs := diffs.push (← printIdCore c i)
for ext in ← persistentEnvExtensionsRef.get do
if let some diff := ← diffExtension old new ext then
diffs := diffs.push diff
if diffs.isEmpty then
return "no new constants"
pure <| MessageData.joinSep diffs.toList "\n\n"