What are the values that are shown when hovering over a variable?

Oh I never knew that. What are the many different versions that it shows? Just examples?

On the image you can only see two, but there are around 9 available with scrolling.

1 Like

What are the many different versions that it shows?

It’s all the instances of it that end up where your cursor is. So if you had two non-block equations then there would be two items in this list. If you had 10 there would be 10 of them.

1 Like

Oh wow. Why would it do that?

(I split this discussion off so that it’s easier to find on its own)

Why wouldn’t it? :P Typst has no way of knowing which execution of the show rule you’re currently interested in, so it shows all.

If I’m interested in something specific, I often create an extra variable for that:

if it.supplement == "Fancy Equation" {
  // hovering over this will only show `it` from certain executions
  let dbg = it
}
2 Likes

I can only speculate about why. So here I go speculating:

Typst relies heavily on memoizing to speed up document compilation. As I understand it this works by saving the output of a function for the given inputs. Then if the function is called again with those same inputs, it can simply return the already-calculated output.
Getting back to the question: there already exists a record of every version of a given variable for the whole document. I assume this makes it pretty trivial to display it like you see when you hover over a variable.
It could also be a way to offer a debugging tool without going through the effort of a full-blown debugging environment.

From a user perspective I’ve found it helpful to see all these while working on a function. When I can’t keep all the variables and scopes in my head this can help get me back on track.

Ah I see, seems reasonable. Thanks for your take :slight_smile: