How can I access shadowed functions?

For example,

#let query(target) = {
  let quarry = // assume something interesting is done
  query(quarry) // I want to run super.query
}

I tried super.query but that wasn’t it.

you can assign the original function to a different name before shadowing it. I prefer an underscore as a prefix, as it is otherwise discouraged by Typst naming conventions:

#let _query = query
#let query(target) = {
  let quarry = // assume something interesting is done
  _query(quarry)
}
1 Like

There actually is another way, though I would prefer the solution of @SillyFreak. If you define your function in a variable as an unnamed function, you can still access the original function inside:

#let query = target => {
  let quarry = // assume something interesting is done
  query(quarry)
}

Also, for completeness, starting with (the soon to be released) version 0.12, you will no longer need to store the original function yourself, as it will be available under the std namespace as std.query.

3 Likes

I can offer another naming scheme I use that is more descriptive: query-old (this also follows the kebab case convention). But yeah, soon this will be irrelevant.