Closed shriram closed 4 years ago
The solution is to not default to extracting the namespace. dynamic-require
can be used to require the name directly using the "external" interface.
If the name isn't found, we have an ambiguity: either the student program is in error, or it's written in a language (like BSL) that doesn't provide the name. Since the BSL issue isn't surmountable, we have to be generous and extract the name (it's reasonable to assume the student wouldn't have uploaded the code if they hadn't wanted it exposed).
In principle we should check the implementing language and only do this if the language is a student language (or at least issue a warning about automatic extraction), but that seems unlikely to be a priority. (Also because other student languages may be built atop BSL, and they will also trigger this warning, which is likely to be confusing to students.)
Because BSL does not export names, we currently use namespace tools to extract the name from inside the module. This works across many languages, but it has a subtle flaw: it does not respect
rename-out
. For instance, inthe value of
four
obtained from requiring the module is3
but when obtained from the module's namespace, it's4
.Therefore, either the name extraction should respect
rename-out
, or we should first try to obtain the name through regular means, and resort to namespace inspection only as a last resort. (A language withoutprovide
has no need forrename-out
, so this should be safe.)