Surprises with `display` and `view`

(Sorry for so many posts. Genuinely trying to be helpful. And I find it better to post each topic in a distinct thread instead of a single long list of issues for purposes of discovery and clarity.)

I think many users will find it very surprising that when display or view are called from inside a function, they present their output in the cell where that function is defined and not where that function is called.

This is confounding enough that I think it would be appropriate to put a brief mention of this where display and view are first introduced in the documentation, with a link to more “advanced” documentation that explains why and provides the solution. The solution being to pass display or view from the calling cell, so that when they are called they have the “correct” scope.

Here is a notebook that walks through my experience with this issue:

https://observablehq.com/d/8596d725dd5d8d16