[ https://issues.apache.org/jira/browse/SYSTEMML-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15230694#comment-15230694 ]
Glenn Weidner commented on SYSTEMML-590: ---------------------------------------- As an example, I downloaded a zip of the deep machine learning scripts from SYSTEMML-618 and ran nn/test/tests.dml against my branch for SYSTEMML-617 without any script-parsing errors. I then removed "util::" from calls to all_equal and compute_rel_error defined in nn/util.dml (used to workaround the issue mentioned in the description). The tests.dml was re-ran without parsing errors which illustrates where the patch from SYSTEMML-617 helps some. However, the "util::" namespace prefix is still required in the file nn/layers/conv.dml. > Improve Namespace Handling for UDFs > ----------------------------------- > > Key: SYSTEMML-590 > URL: https://issues.apache.org/jira/browse/SYSTEMML-590 > Project: SystemML > Issue Type: Sub-task > Reporter: Mike Dusenberry > > Currently, if a UDF body involves calling another UDF, the default global > namespace is assumed, unless a namespace is explicitly indicated. This > becomes a problem when a file contains UDFs, and is then sourced from another > script. > Imagine a file {{funcs.dml}} as follows: > {code} > f = function(double x, int a) return (double ans) { > x2 = g(x) > ans = a * x2 > } > g = function(double x) return (double ans) { > ans = x * x > } > {code} > Then, let's try to call {{f}}: > {code} > script = """ > source ("funcs.dml") as funcs > ans = funcs::f(3, 1) > print(ans) > """ > ml.reset() > ml.executeScript(script) > {code} > This results in an error since {{f}} is in the {{funcs}} namespace, but the > call to {{g}} assumes {{g}} is still in the default namespace. Clearly, the > user intends to the use the {{g}} that is located in the same file. > Currently, we would need to adjust {{funcs.dml}} as follows to explicitly > assume that {{f}} and {{g}} are in a {{funcs}} namespace: > {code} > f = function(double x, int a) return (double ans) { > x2 = funcs::g(x) > ans = a * x2 > } > g = function(double x) return (double ans) { > ans = x * x > } > {code} > Instead, it would be better to simply first look for {{g}} in its parent's > namespace. In this case, the "parent" would be the function {{f}}, and the > namespace we have selected is {{funcs}}, although that choice would be left > up to the end-user. Then, namespace assumptions would not be necessary. -- This message was sent by Atlassian JIRA (v6.3.4#6332)