octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help needed with function handles (was: Re: need help with function hand


From: John W. Eaton
Subject: Help needed with function handles (was: Re: need help with function handle tests)
Date: Tue, 17 Mar 2020 13:48:45 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 3/16/20 7:50 PM, Ray Daniel Zimmerman wrote:
Is this better?

Yes, thanks.

From what I can tell, ALL function handles have the following fields (as reported by the calls to 'functions'):

  function: NAME or CODE
      type: anonymous, simple, scopedfunction, nested, classsimple
      file: NAME, may be empty


They may have the additional fields for specific function handle types, and field values may provide more info about what should happen when performing searches for functions):

simple (ordinary functions including package functions and static class methods)

    no extra fields
    file: '' (for package functions and static class methods)


  anonymous:

           workspace: {[1x1 struct]}
    within_file_path: '' (when is this empty or not?)

  scopedfunction (private, sub, and local functions)

    examples:

    parentage: {'privfun'}
    parentage: {'subfun'  'parentfun'}
    parentage: {'lcl'  'myclass.myclass%fromTopLevel'}

  nested:

   workspace: {[1x1 struct]}

  classsimple (class method):

       class: 'myclass'
        file: ''


It looks like we need to change the implementation of function handles to store the above info directly and perform lookups somewhat differently. Instead of deferring most lookups until a function handle is used, we need to look for functions in the scope where the handle is created so we can determine whether there is a nested or scoped (private, sub or local) function that would take precedence over any globally visible function. Then if functions are cleared, we can reload the necessary functions to recover the function definition. I believe that the persistent variable values in the tests I posted show that function handles don't grab a copy (or reference count that would prevent clearing) of the functions they refer to and that the functions are reloaded if they are cleared. And this reloading may happen even if the load path changes so that the function referenced by the handle is no longer visible in the load path.

Please correct me if any of the above doesn't look right.

If someone has some insight about how the rules for function handles are really simple, please let me know, because at the moment, it seems that the rules are somewhat complex and there are a lot of cases to consider.

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]