octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #62111] scope resolution operator addition to


From: Rik
Subject: [Octave-bug-tracker] [bug #62111] scope resolution operator addition to Octave language
Date: Sun, 27 Feb 2022 20:24:51 -0500 (EST)

Update of bug #62111 (project octave):

                Severity:              3 - Normal => 1 - Wish               
                Priority:              5 - Normal => 3 - Low                
              Item Group:                    None => Feature Request        
                 Release:                   6.4.0 => dev                    
        Operating System:       Microsoft Windows => Any                    
                 Summary: missing scope resolution operator => scope
resolution operator addition to Octave language

    _______________________________________________________

Follow-up Comment #1:

Re-titling report and changing release to the development branch.  This would
be a major addition to the Octave language.  This is not a feature Matlab
implements and web searches show that this issue has come up from time to
time, but that Matlab has made no changes to their language.

There are various ways to workaround the issue with the current language.

Method #1 : function handles

Function handles store a pointer to a function and that pointer is recorded at
the time of creation of the function handle and doesn't change thereafter. 
One can use the fact that the current directory is the first item on the
path() to ensure that a function handle stores the version of the m-file you
want.  The sample code below assumes that the function with a duplicate
filename is named "fname.m", dir1 is the directory of the first m-file
instance and dir2 is the directory of the second mfile instance.


old_pwd = pwd;
cd dir1
fcn1 = @fname;
cd dir2
fcn2 = @fname;
cd (old_pwd)


Once the function handles are defined you can call whichever one you want with
ordinary function handle syntax such as "fcn1 (x, y, z)".

Method #2 : rmpath / addpath

If there are two m-files with the same name then Octave or Matlab will execute
the one that occurs first in the load path.  Assume that the first function is
in dir1 which occurs before dir2 in the search path.  In that case, there is
no problem executing fcn1 whenever you want.  However, to execute fcn2 do
this


rmpath (dir1)
fname (...)  # Call fcn2
addpath (dir1)  # Restore fcn1 to be earlier in the loadpath




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62111>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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