numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
205 stars 120 forks source link

Find variables in global scope used inside custom JME functions #470

Open christianp opened 7 years ago

christianp commented 7 years ago

Suppose I have a JME function random_person() which returns random(people), where people is a variable defined in the global scope.

Numbas.jme.findvars should inspect the definition of random_person to find out that it uses people. At the moment it doesn't, which means variables can be generated in the wrong order sometimes.

christianp commented 5 years ago

Not sure this can be done, since multiple dispatch means that the interpretation of a function name depends on the types of the evaluated arguments. If there are two definitions of random_person, each using different global variables, with one taking a boolean argument and one taking a string, we can't decide which one is being used without evaluating the arguments.