You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@systemml.apache.org by "Mike Dusenberry (JIRA)" <ji...@apache.org> on 2016/05/12 18:43:12 UTC
[jira] [Resolved] (SYSTEMML-590) Improve Namespace Handling for
UDFs
[ https://issues.apache.org/jira/browse/SYSTEMML-590?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mike Dusenberry resolved SYSTEMML-590.
--------------------------------------
Resolution: Fixed
Fix Version/s: SystemML 0.10
> Improve Namespace Handling for UDFs
> -----------------------------------
>
> Key: SYSTEMML-590
> URL: https://issues.apache.org/jira/browse/SYSTEMML-590
> Project: SystemML
> Issue Type: Improvement
> Components: Parser
> Affects Versions: SystemML 0.10
> Reporter: Mike Dusenberry
> Assignee: Glenn Weidner
> Fix For: SystemML 0.10
>
>
> 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)