In MiniScript 2, I'd like to associate a bit of extra metadata with each function (accessible via any funcRef):
- name: the text of the expression to the left of
= where the function was defined, if any
- note: when the first statement of a function body evaluates to a string constant, it is stored as the note (similar to a Python docstring)
- params: a list of little maps, one for each parameter; each contains
name and default (the actual default value)
- sourceLoc: the location of this function definition in the source code
The question is, how do you access this information?
My current top idea: a new info intrinsic which, given a funcRef, returns a little frozen map with the above information. So you could use info(@f).note to get to the note about function f, or info(@f).sourceLoc to find out where in the source this function came from.
What do you think of this idea? Is it a good name? Is there some other approach entirely that you would prefer? (We can't just say f.note because that would invoke f, and then try to look up note on whatever f returns.)