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:41:13 UTC

[jira] [Comment Edited] (SYSTEMML-590) Improve Namespace Handling for UDFs

    [ https://issues.apache.org/jira/browse/SYSTEMML-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15281897#comment-15281897 ] 

Mike Dusenberry edited comment on SYSTEMML-590 at 5/12/16 6:41 PM:
-------------------------------------------------------------------

This has been a lot of work, and UDFs/namespaces are much better now.  Thanks, [~gweidner]!


was (Author: mwdusenb@us.ibm.com):
This has been a lot of work, and UDFs are much better now.  Thanks, [~gweidner]!

> 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
>
> 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)